-
-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for flow and typescript generic type parameters
- Loading branch information
1 parent
36fc0a1
commit 4cb1f3b
Showing
10 changed files
with
557 additions
and
106 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
|
||
import React, { Component } from 'react'; | ||
|
||
type Test<X> = Array<X>; | ||
interface BaseProps<T> { | ||
/** Optional prop */ | ||
foo?: T, | ||
/** Required prop */ | ||
bar: Test<T> | ||
} | ||
|
||
interface Child {} | ||
|
||
interface Props extends BaseProps<Child> { | ||
/** Complex union prop */ | ||
baz: number | ||
} | ||
|
||
/** | ||
* This is a typescript class component | ||
*/ | ||
export default class TSComponent extends Component<Props> { | ||
render() { | ||
return <h1>Hello world</h1>; | ||
} | ||
} |
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,33 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
|
||
import React, { Component } from 'react'; | ||
|
||
type Test<X> = Array<X>; | ||
interface BaseProps<T> { | ||
/** Optional prop */ | ||
foo?: T, | ||
/** Required prop */ | ||
bar: Test<T> | ||
} | ||
|
||
interface Child {} | ||
|
||
interface Props extends BaseProps<Child> { | ||
/** Complex union prop */ | ||
baz: number | ||
} | ||
|
||
/** | ||
* This is a typescript class component | ||
*/ | ||
export default class FlowComponent extends Component<Props> { | ||
render() { | ||
return <h1>Hello world</h1>; | ||
} | ||
} |
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
Oops, something went wrong.