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
When using [Closure Components](components.md#closure-component-state) in JSX, TypeScript only expects an attribute object as a parameter for a Function Component. But Mithril provides a `Vnode` object instead. This leads to the IDE showing faulty parameters even though the JSX would compile correctly.
284
284
285
-
Example:
286
-
The following code will compile correctly but show this error:
287
-
```
288
-
TS2739: Type { greet: string; } is missing the following properties from type Vnode<{}, {}>: tag, attrs, state
289
-
TS2786: LoadingSpinner cannot be used as a JSX component.
290
-
```
285
+
For example, if you try to compile this code:
291
286
292
287
```typescript jsx
293
288
interfaceAttributes {
@@ -306,6 +301,13 @@ function ParentComponent() {
306
301
}
307
302
```
308
303
304
+
TypeScript will report this error:
305
+
306
+
```
307
+
TS2739: Type { greet: string; } is missing the following properties from type Vnode<{}, {}>: tag, attrs, state
308
+
TS2786: LoadingSpinner cannot be used as a JSX component.
309
+
```
310
+
309
311
There are several options to circumvent that problem:
310
312
1) Instead of `<div><ChildComponent greet="Hello World"/></div>`, use `<div>{m(ChildComponent, {greet: "Hello World"})}</div>` instead.
311
313
2) Use [Class Components](components.md#class-component-state) instead. Class Components will not show any errors. But TypeScript will not be able to autocomplete or inspect attributes (in this example `greet` would be unknown when used in `ParentComponent`).
0 commit comments