我有这个通量商店课程:
'use strict';
import flux = require('app/tools/flux');
import types = require('app/tools/types');
import Actions = require('app/actions/actions');
class Store
{
bindListeners(config : any) : void {;};
books : Array<types.IBook>;
selectedBookName : string;
...
}
export = flux.createStore<Store>(Store, 'Store');
在此视图中使用的是:
"use strict";
import React = require('react');
import Store = require('app/stores/store'); // <-- here we import the Store
import _ = require('lodash');
import BookHelper = require('app/tools/bookHelper');
import Msg = require('app/tools/messages');
interface props {}
interface state {}
class NoteContainer extends React.Component<props, state>
{
state: typeof Store; // <-- this is Altjs<Store>, not Store :(
render()
{
if (!this.state.selectedBookName) // <-- here's an error
return;
...
这给出了编译错误:
error TS2339: Property 'selectedBookName' does not exist on type 'AltStore<Store>'.
如何将视图的状态设置为实际的Store类,而不是AltStore<Store>
类?即如何获取泛型参数的类型,如下所示:
state: typeof Store<THIS THING>