-
-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for importing types #352
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
00b3d35
Initial support for importing prop types
devongovett 268b828
Add noop browser version of resolveImportedValue
devongovett 840ca88
Handle namespace imports
devongovett 79a814f
Support export all declaration
devongovett 80200c8
Handle recursive imports
devongovett c180af8
Support named re-exports
devongovett 08b5e7f
Fix lint
devongovett 8c0a15f
Missing typedef
devongovett 02649b7
Merge branch 'master' into importing
danez 26874ee
Merge branch 'master' into importing
danez e69ef4f
Add mjs
danez 048646d
Fix order of deps
danez 3b3bbf6
Add additional test
danez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
|
||
import React, { Component } from 'react'; | ||
|
||
interface Props { | ||
export interface Props { | ||
foo: string | ||
} | ||
|
||
|
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,17 @@ | ||
/** | ||
* 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'; | ||
import ExtendedProps from './component_28'; | ||
|
||
/** | ||
* This is a typescript component with imported prop types | ||
*/ | ||
export function ImportedExtendedComponent(props: ExtendedProps) { | ||
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,13 @@ | ||
import Button from './component_6'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export function CustomButton({color, ...otherProps}) { | ||
return <Button {...otherProps} style={{color}} />; | ||
} | ||
|
||
CustomButton.propTypes = { | ||
...Button.propTypes, | ||
color: PropTypes.string | ||
}; | ||
|
||
export const sharedProps = Button.propTypes; |
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,10 @@ | ||
import {CustomButton, sharedProps} from './component_30'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export function SuperCustomButton({color, ...otherProps}) { | ||
return <CustomButton {...otherProps} style={{color}} />; | ||
} | ||
|
||
SuperCustomButton.propTypes = sharedProps; | ||
export {sharedProps}; | ||
export * from './component_32'; |
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,9 @@ | ||
import {SuperCustomButton, sharedProps} from './component_31'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export function SuperDuperCustomButton({color, ...otherProps}) { | ||
return <SuperCustomButton {...otherProps} style={{color}} />; | ||
} | ||
|
||
SuperDuperCustomButton.propTypes = sharedProps; | ||
export * from './component_31'; |
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,9 @@ | ||
import * as C31 from './component_32'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export function SuperDuperCustomButton({color, ...otherProps}) { | ||
return <C31.SuperCustomButton {...otherProps} style={{color}} />; | ||
} | ||
|
||
SuperDuperCustomButton.propTypes = C31.sharedProps; | ||
export {SuperCustomButton} from './component_32'; |
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 @@ | ||
import {SuperCustomButton} from './component_33'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export function SuperDuperCustomButton({color, ...otherProps}) { | ||
return <SuperCustomButton {...otherProps} style={{color}} />; | ||
} | ||
|
||
SuperDuperCustomButton.propTypes = SuperCustomButton.propTypes; |
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,21 @@ | ||
/** | ||
* 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'; | ||
import { Props as ImportedProps } from './component_27'; | ||
|
||
export default interface ExtendedProps extends ImportedProps { | ||
bar: number | ||
} | ||
|
||
/** | ||
* This is a typescript component with imported prop types | ||
*/ | ||
export function ImportedComponent(props: ImportedProps) { | ||
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,16 @@ | ||
import { Sizes } from '../common'; | ||
import T from 'prop-types'; | ||
|
||
function SuperDuperCustomButton() { | ||
return <div />; | ||
} | ||
|
||
SuperDuperCustomButton.defaultProps = { | ||
size: Sizes.EXTRA_LARGE, | ||
}; | ||
|
||
SuperDuperCustomButton.propTypes = { | ||
size: T.oneOf(Object.values(Sizes)), | ||
}; | ||
|
||
export default SuperDuperCustomButton; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't looked at the implementation yet, but this snapshot reflects the current behaviour. Is it safe to assume this PR does not (yet) handle this behaviour, but it will given this test was checked in? I'm expecting both of these references to
Sizes
to resolve to a value rather than those string literals.Also,
../common
is not implemented - not sure if on purpose or not.