Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

"Class XXX used before its declaration" breaking change in 2.3.0 #15102

Copy link
Copy link
@s-panferov

Description

@s-panferov
Issue body actions

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

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.