Skip to content

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

@s-panferov

Description

@s-panferov

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?

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions