Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flow: interface identifier should be declared in the scope (#10220)
* fix: typo * declare name for flow interface * add test case for export overload function, typescript * test: add test Fixes #10044 * test: update test * test(flow): add multiple declarations regression test * re-enable flow test case # Conflicts: # packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/def-site-variance/input.js # packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-declare-statements/input.js # packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-interfaces-module-and-script/input.js # packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-iterator/input.js * test: disable two flow dupl-decl test * fix: do not declare name for declare function until we figure out a better way * test: duplicate declare function and function would not throw
- Loading branch information
1 parent
02f2d17
commit fa5057f
Showing
78 changed files
with
2,013 additions
and
76 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
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
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
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
4 changes: 2 additions & 2 deletions
4
packages/babel-generator/test/fixtures/flow/internal-slot/input.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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
declare class C { static [[foo]]: T } | ||
declare class C { [[foo]]: T } | ||
interface I { [[foo]]: X } | ||
interface I { [[foo]](): X } | ||
interface I1 { [[foo]]: X } | ||
interface I2 { [[foo]](): X } | ||
type T1 = { [[foo]]: X } | ||
type T2 = { [[foo]](): X } | ||
type T3 = { [[foo]]?: X } |
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
4 changes: 2 additions & 2 deletions
4
packages/babel-generator/test/fixtures/flow/iterator-inside-interface/input.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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
interface A { | ||
interface A1 { | ||
@@iterator(): Iterator<File>; | ||
} | ||
|
||
interface A { | ||
interface A2 { | ||
@@asyncIterator(): Iterator<File>; | ||
} |
4 changes: 2 additions & 2 deletions
4
packages/babel-generator/test/fixtures/flow/iterator-inside-interface/output.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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
interface A { | ||
interface A1 { | ||
@@iterator(): Iterator<File> | ||
} | ||
interface A { | ||
interface A2 { | ||
@@asyncIterator(): Iterator<File> | ||
} |
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
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
3 changes: 3 additions & 0 deletions
3
.../babel-parser/test/fixtures/flow/interfaces-module-and-script/implements-exports/input.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,3 @@ | ||
interface Foo {} | ||
|
||
export type { Foo } |
160 changes: 160 additions & 0 deletions
160
...bel-parser/test/fixtures/flow/interfaces-module-and-script/implements-exports/output.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,160 @@ | ||
{ | ||
"type": "File", | ||
"start": 0, | ||
"end": 37, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 19 | ||
} | ||
}, | ||
"program": { | ||
"type": "Program", | ||
"start": 0, | ||
"end": 37, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 19 | ||
} | ||
}, | ||
"sourceType": "module", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "InterfaceDeclaration", | ||
"start": 0, | ||
"end": 16, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 16 | ||
} | ||
}, | ||
"id": { | ||
"type": "Identifier", | ||
"start": 10, | ||
"end": 13, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 10 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 13 | ||
}, | ||
"identifierName": "Foo" | ||
}, | ||
"name": "Foo" | ||
}, | ||
"typeParameters": null, | ||
"extends": [], | ||
"implements": [], | ||
"mixins": [], | ||
"body": { | ||
"type": "ObjectTypeAnnotation", | ||
"start": 14, | ||
"end": 16, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 14 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 16 | ||
} | ||
}, | ||
"callProperties": [], | ||
"properties": [], | ||
"indexers": [], | ||
"internalSlots": [], | ||
"exact": false | ||
} | ||
}, | ||
{ | ||
"type": "ExportNamedDeclaration", | ||
"start": 18, | ||
"end": 37, | ||
"loc": { | ||
"start": { | ||
"line": 3, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 19 | ||
} | ||
}, | ||
"specifiers": [ | ||
{ | ||
"type": "ExportSpecifier", | ||
"start": 32, | ||
"end": 35, | ||
"loc": { | ||
"start": { | ||
"line": 3, | ||
"column": 14 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 17 | ||
} | ||
}, | ||
"local": { | ||
"type": "Identifier", | ||
"start": 32, | ||
"end": 35, | ||
"loc": { | ||
"start": { | ||
"line": 3, | ||
"column": 14 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 17 | ||
}, | ||
"identifierName": "Foo" | ||
}, | ||
"name": "Foo" | ||
}, | ||
"exported": { | ||
"type": "Identifier", | ||
"start": 32, | ||
"end": 35, | ||
"loc": { | ||
"start": { | ||
"line": 3, | ||
"column": 14 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 17 | ||
}, | ||
"identifierName": "Foo" | ||
}, | ||
"name": "Foo" | ||
} | ||
} | ||
], | ||
"source": null, | ||
"exportKind": "type", | ||
"declaration": null | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/babel-parser/test/fixtures/flow/multiple-declarations/class/input.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 @@ | ||
declare class C1 {} | ||
class C1 {} |
8 changes: 8 additions & 0 deletions
8
packages/babel-parser/test/fixtures/flow/multiple-declarations/class/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,8 @@ | ||
{ | ||
"sourceType": "module", | ||
"plugins": [ | ||
"jsx", | ||
"flow" | ||
], | ||
"throws": "Identifier 'C1' has already been declared (2:6)" | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/babel-parser/test/fixtures/flow/multiple-declarations/declare-class/input.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,6 @@ | ||
declare class C1{} | ||
declare class C1{} | ||
|
||
declare module M1 { | ||
declare class C1 {} | ||
} |
Oops, something went wrong.