-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Description
Bug Report
π Search Terms
proptypes
4.4 proptypes
prop types
proptype function
π Version & Regression Information
- This changed between versions 4.3.5 and 4.4
β― Playground Link
declare function Select({ myFunc }: {
myFunc?: any;
}): JSX.Element;Now see the difference with 4.4 playground
declare function Select({ myFunc }: {
myFunc?: null | undefined;
}): JSX.Element;myFunc is no longer allowed to be, well, anything except null/undefined, when it should be any
Note that this appears to happen in 4.4 when I turn on strictNullChecks - if you turn that toggle off in 4.4, it goes back to the myFunc?: any; def, so there appears to be something going on there maybe? I can't tell if this is some sort of interaction with the new exactOptionalPropertyTypes toggle or what, though if I turn that off in 4.4 it still doesn't change the .d.ts. So π€·
π» Code
import React from 'react'
import PropTypes from 'prop-types'
const Select = ({myFunc = null}) => {
return <button onClick={() => myFunc?.()}>hi</button>
}
Select.propTypes = {
myFunc: PropTypes.func
}
export default Selectπ Actual behavior
myFunc?: null | undefined;myFunc is only allowed to be null | undefined
π Expected behavior
myFunc?: any;myFunc is any
From reading the release blog post, I don't notice anything that would appear to change this behavior. I could have misunderstood or missed it though!