TypeScript/tests/cases/compiler/nonNullReferenceMatching.ts
2019-01-10 14:45:19 -08:00

34 lines
1.3 KiB
TypeScript

// @strict: true
type ElementRef = (element: HTMLElement | null) => void;
type ThumbProps = {
elementRef?: ElementRef;
}
type ComponentProps = {
thumbYProps?: ThumbProps;
thumbXProps: ThumbProps;
}
class Component {
props!: ComponentProps;
public thumbYElementRef = (ref: HTMLElement | null) => {
typeof this.props.thumbYProps!.elementRef === 'function' && this.props.thumbYProps!.elementRef(ref);
typeof (this.props.thumbYProps!.elementRef) === 'function' && this.props.thumbYProps!.elementRef(ref);
typeof ((this.props).thumbYProps!.elementRef)! === 'function' && this.props.thumbYProps!.elementRef(ref);
typeof this.props.thumbXProps.elementRef === 'function' && this.props.thumbXProps.elementRef(ref);
typeof this.props.thumbXProps.elementRef === 'function' && (this.props).thumbXProps.elementRef(ref);
typeof this.props.thumbXProps.elementRef === 'function' && (this.props.thumbXProps).elementRef(ref);
typeof this.props.thumbXProps.elementRef === 'function' && ((this.props)!.thumbXProps)!.elementRef(ref);
typeof (this.props.thumbXProps).elementRef === 'function' && ((this.props)!.thumbXProps)!.elementRef(ref);
typeof this.props!.thumbXProps!.elementRef === 'function' && ((this.props)!.thumbXProps)!.elementRef(ref);
};
}