有一个<input type="checkbox" id="mainCheckbox" />,我想使用它的属性checked.和vscode waring Property 'checked' does not exist on type 'HTMLElement'.我知道必须是类型HTMLInputElement,但是我不能改变它,方法getElementById()是返回类型HTMLElement;
var controlCheckbox= document.getElementById("mainCheckbox"),
addBtn = document.getElementById("btn_add"),
container = document.getElementById("observers");
ObserverSubject.extend(new ObserverSubject.Subject(), controlCheckbox);
controlCheckbox.onclick=()=>{
this.Notify(controlCheckbox.checked);
}
Run Code Online (Sandbox Code Playgroud)
打字稿:2.8.3
@类型/反应:16.3.14
JSX.Element当我将组件声明为React.SFC(的别名 React.StatelessComponent)时,函数component的返回类型为。
发生了三个错误?
TS2322: Type 'Element' is not assignable to type 'StatelessComponent<{}>', Type 'Element' provides no match for the signature '(props: { children?: ReactNode; }, context?: any): ReactElement<any>'
TS2339: Property 'propTypes' does not exist on type '(props: LayoutProps) => StatelessComponent<{}>'
TS2339: Property 'defaultProps' does not exist on type '(props: LayoutProps) => StatelessComponent<{}>'
interface ItemInterface {
name: string,
href: string,
i18n?: string[]
}
interface LayoutHeaderItemProps extends ItemInterface{
lang: string,
activeHref: string,
}
function LayoutHeaderItem (props: …Run Code Online (Sandbox Code Playgroud) 我想在typescript中使用destructuring,示例代码:
var {first, second} = { first: "one", second: "two" }
console.log(first);
Run Code Online (Sandbox Code Playgroud)
我的编译命令tsc --t es5 destructuring.ts,
打字稿版本1.6.2,
IDE是vs code.
然后导致三个错误:
destructuring.ts(1,5): error TS1008: Unexpectedtoken; 'identifier' expected.
destructuring.ts(1,21): error TS1008: Unexpected token; 'module, class, interface, enum, import or statement' expected.
destructuring.ts(1,45): error TS1005: ';' expected.;
在我的桌面(窗口8.1 x64)中,命令npm -g list,显示typescript@1.6.2和命令 tsc --version显示Version 1.0.3.0:
但在我的笔记本电脑(Windows 7 x64)中,命令tsc --version显示message TS6029: Version 1.6.2:

像上面的知情同意,我谨目录__tests__和文件LinkButton.js从demo到jest,然后运行npm test -- --coverage在终端.
测试通过,但覆盖范围错误.似乎开玩笑缓存了旧路径.
开玩笑怎么了?在线等待,非常感谢.
GitHub:https://github.com/codelegant/react-action/tree/master/public/src