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 has been archived by the owner on Sep 25, 2019. It is now read-only.
The downside is that you lose the type inference that item belongs to this.items - hopefully we'll be able to extend TypeScript in future to let it know about this properly.
Auto-Imports
You will need to manually import decorators, and manually extend the base class for components that do this for you. i.e.:
@Component({ events: ['accept'] })
class MyComponent {
}
becomes:
import { Component, BaseComponent } from '@twist/react';
@Component({ events: ['accept'] })
class MyComponent extends BaseComponent {
}
Ideally this would support generics, but I don't think the spirit of the following is possible (would be nice if there's a way to encode this though!):
We need to document how to use TypeScript with React-Twist, along with a sample application.
The main complexity comes from the following language features:
<repeat>
and<using>
).@Component
).Right now, TypeScript does not have a plugin model, but this will possibly change (see microsoft/TypeScript#16607).
In the meantime, we'd need to document how to use Twist with TypeScript.
JSX Variable Declarations
Use
<repeat collection={ this.items } as={ item }>
rather than<repeat for={ item in this.items }>
When you use
as={ varname }
to define a variable, you need to add a declaration to the top of the containing function. e.g.:The downside is that you lose the type inference that
item
belongs tothis.items
- hopefully we'll be able to extend TypeScript in future to let it know about this properly.Auto-Imports
You will need to manually import decorators, and manually extend the base class for components that do this for you. i.e.:
becomes:
Type Declarations
On the plus side, TypeScript supports interfaces for intrinsic elements (see https://www.typescriptlang.org/docs/handbook/jsx.html), so we can provide some typing for
<if>
,<repeat>
etc.Ideally this would support generics, but I don't think the spirit of the following is possible (would be nice if there's a way to encode this though!):
We'd also need to define TypeScript interfaces for the core Twist classes (Component, Store, SignalDispatcher etc etc).
The text was updated successfully, but these errors were encountered: