mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
🤖 Merge PR #45780 Fix react-router hooks test by @sandersn
microsoft/TypeScript#39081, which ships in Typescript 4.0, stops using binding patterns as contextual types for return type inference. react-router's `useParams` relied on this to fill in an object with `any`s in case a binding pattern was used but no type argument was provided. This no longer works. This fix just adds a type argument to the tests. For two other, more complete fixes, see https://github.com/microsoft/TypeScript/pull/39081#issuecomment-644393729 Briefly, the options are (1) go back to returning `any`-filled object types or (2) tries to default to `string`. The second fix is probably the right one, but it may hurt compilation/IDE performance, so I'll leave it to the package owners to decide whether to make that change.
This commit is contained in:
parent
42b597fab0
commit
cbbbfecf45
@ -21,7 +21,7 @@ interface LocationState {
|
||||
const HooksTest: React.FC = () => {
|
||||
const history = useHistory<LocationState>();
|
||||
const location = useLocation<LocationState>();
|
||||
const { id } = useParams();
|
||||
const { id } = useParams<Params>();
|
||||
const params = useParams<Params>();
|
||||
// $ExpectType OptionalParams
|
||||
const optionalParams = useParams<OptionalParams>();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user