我有一个界面
@echo off
@echo off
for /f "delims=" %%i in ('dir "c:\20*" /b /ad /o-d') do set "latest=%%i" & goto :comp
:comp
for /f "tokens=1 delims=" %%a in ('PowerShell -Command "& {Get-Date -format "yyyyMM"}"') do if "%%a" == "%latest%" echo Zip/7z/Rar C:\%latest% here
和引用该文件的同一文件中的类
interface ITodoFilterItem {
name: string,
filter: string,
filterTodos: any
}
但是当我尝试在该文件的底部添加propTypes时
class TodoFilterItem extends Component<ITodoFilterItem> {
constructor (props:ITodoFilterItem) {
super(props);
this.handleFilter = this.handleFilter.bind(this);
}
我得到:
TodoFilterItem.propTypes = {
name: PropTypes.string,
filter: PropTypes.string,
filterTodos: PropTypes.any
}
fyi:我的顶部是Property 'propTypes' does not exist on type 'typeof TodoFilterItem'. TS2339
答案 0 :(得分:2)
TS要求在类定义中初始化所有静态属性。将以下内容添加到您的课程中,以确保TS可以正确分析该课程。
static propTypes: {
name: Requireable<string>;
filter: Requireable<string>;
filterTodos: Requireable<any>;
};
import React, { Component, Requireable } from 'react';
import PropTypes from 'prop-types';
interface ITodoFilterItem {
name: string;
filter: string;
filterTodos: any;
}
class TodoFilterItem extends Component<ITodoFilterItem> {
static propTypes: {
name: Requireable<string>;
filter: Requireable<string>;
filterTodos: Requireable<any>;
};
constructor(props: ITodoFilterItem) {
super(props);
this.handleFilter = this.handleFilter.bind(this);
}
handleFilter() {}
render() {
return <span />;
}
}
TodoFilterItem.propTypes = {
name: PropTypes.string,
filter: PropTypes.string,
filterTodos: PropTypes.any,
};
export default TodoFilterItem;