Skip to content

Commit b2838f9

Browse files
committed
feat!: type inference for event parameters
fixes #8
1 parent 189e1f3 commit b2838f9

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Added
11+
12+
- type inference for event parameters (fixes #8)
13+
814
## [1.1.0] - 2021-04-02
915

1016
### Added

index.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@ type Merge<T, U> = Omit<T, keyof U> & U;
88
type PropsWithAs<P, T extends React.ElementType> = P & { as?: T };
99

1010
export type PolymorphicPropsWithoutRef<P, T extends React.ElementType> = Merge<
11-
React.ComponentPropsWithoutRef<T>,
11+
T extends keyof JSX.IntrinsicElements
12+
? React.PropsWithoutRef<JSX.IntrinsicElements[T]>
13+
: React.ComponentPropsWithoutRef<T>,
1214
PropsWithAs<P, T>
1315
>;
1416

1517
export type PolymorphicPropsWithRef<P, T extends React.ElementType> = Merge<
16-
React.ComponentPropsWithRef<T>,
18+
T extends keyof JSX.IntrinsicElements
19+
? React.PropsWithRef<JSX.IntrinsicElements[T]>
20+
: React.ComponentPropsWithRef<T>,
1721
PropsWithAs<P, T>
1822
>;
1923

0 commit comments

Comments
 (0)