-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: typescript@rc 2.3.0
Code
export interface IconProps {
size?: number;
}
// I use this to create a type that has `size` non-nullable
// (because it always present due to `defaultProps`
type SafeProps = IconProps & typeof Icon.defaultProps;
export default class Icon extends React.Component<IconProps, any> {
static defaultProps = {
size: 10
};
render() {
// cast to SafeProps to safely extract `size`
const { size } = this.props as SafeProps
return <div style={{ size }} />
}
}Expected behavior:
It compiles. This actually works in 2.2.2
Actual behavior:
Class 'Icon' used before its declaration on line type SafeProps = IconProps & typeof Icon.defaultProps;
Is this an intended breaking change?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue