You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 19, 2025. It is now read-only.
In the last couple of years, I felt in love with the TypeScript type system.
97
97
It is so powerful and flexible that it allows you to write DSL with validation that other languages would dream of.
98
-
A lot of colleagues still argue that this kind of knowledge on the specific part of TypeScript, but I strongly
98
+
A lot of colleagues still argue that this kind of knowledge on the specific part of TypeScript is useless, but I strongly
99
99
disagree.
100
100
Why? Because in this post, I will show you a practical application of the knowledge I acquired to solve the
101
101
problem above.
102
102
In particular, we want to avoid coding two different interfaces,
103
103
but just creating a new one starting from the `OverlayProps`
104
-
that adds the `$` sign to the ones that should be transient props, and skips `$`
105
-
for the ones that are DOM attributes.
104
+
that adds the `$` sign to the ones that should be transient props, and skips the other ones that are DOM attributes.
106
105
107
106
#### Implementation
108
107
@@ -112,7 +111,7 @@ Based on the description above, we want to define a `TransientProps` type that i
112
111
* skip the DOM props in some way, because they should still be forwarded
113
112
114
113
To start the implementation, we need first to check some types exposed by React.
115
-
In particular for our use case it will be useful the [`ComponentProps` type](https://react-typescript-cheatsheet.netlify.app/docs/react-types/ComponentProps).
114
+
For our use case it will be useful the [`ComponentProps` type](https://react-typescript-cheatsheet.netlify.app/docs/react-types/ComponentProps).
116
115
This utility type lets us extract the props of a React component received as generic parameter.
117
116
The other interesting type is `React.JSX.IntrinsicElements`.
118
117
This is a type that declares which JSX elements are allowed/defined and their props.
0 commit comments