之后在.tsx文件中使用类型记录
import injectTapEventPlugin = require('react-tap-event-plugin')
injectTapEventPlugin()
通过这份联合来文:
<div onTouchTap={ this.showFront }>
我得到语法错误:
error TS2339: Property 'onTouchTap' does not exist on type 'HTMLProps<HTMLDivElement>'.
尽管
interface HTML
新的TypeScript,并试图从js转换为ts (使用角1.x)。这是一个控制器。转换成ts有问题。“模块”是ui路由器状态提供程序上的自定义数据元素。
(function(module) {
"use strict";
module.controller("aboutController", [
"$state",
function($state) {
var vm = this;
// pass the module to the service
我想知道为什么当您将类名放入querySelectorAll时,类型不再以HTMLDivElement的形式出现。
document.querySelectorAll('div').forEach(item => {
// item type is HTMLDivElement
});
document.querySelectorAll('div.className').forEach(item => {
// item type is Element not HTMLDivElement
});
这意味着,如果我想要更改样式,就会
我得到以下错误:
type Union = { type: "1"; foo: string } | { type: "2"; bar: number };
function doSomething = (object: Union) => {
const { foo } = object
// ^ TS2339: Property 'foo' does not exist on type 'Union'.
console.log(object.bar)
// ^
我想问一下宽度上的打字错误
我创建了这个组件(进度栏),其中我使用对组件进行样式化,但是即使我在其中放置类型,类型记录也会引发这种错误。
import { FunctionComponent, ReactComponentElement } from 'react';
//style
import { styled } from 'stitches';
import type * as Stitches from '@stitches/react';
//components
import Typo from '@components
使用foo作为属性引发错误:
// App.tsx
// throws
const App = () => <div foo></div>
export default App
Type '{ foo: true; }' is not assignable to type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'.
Property 'foo' does
在一个用typescript编译的项目上使用Angular 2。
尝试创建blob图像时出现此错误:
error TS2339: Property 'webkitURL' does not exist on type 'Window'
ts代码为:
public url = window.URL || window.webkitURL; this.photo = this.url.createObjectURL( res );
我试图采用现有的ngrx状态并将其重构为子特性modules.The问题是当我在我的功能模块导入中使用StoreModule.forFeature时.我在编译过程中遇到了一个错误:
ERROR in [at-loader] ./src/app/components/login/login.module.ts:67:21
TS2339: Property 'forFeature' does not exist on type 'typeof StoreModule'.
实际上,我在node_modules/@ngrx/store中搜索了"forFeatur
TypeScript似乎是基于微软对DOM和JS的理解。如果我不关心IE‘an Edge会发生什么?我和TypeScript有问题..。
例如。Element.getBoundingClientRect()返回具有x和y属性的对象--在除IE和边缘之外的所有浏览器中(参见备注)。
所以我有 TS2339: Property 'x' does not exist on type 'ClientRect | DOMRect'.
我能说服编译器不要担心这个吗?
我见过和其他类似的帖子,甚至在中做了我想做的事情,但在VS中我得到了红色下划线和构建错误。
错误文本:Error TS2339 Build:Property 'contains' does not exist on type 'String'.
我是不是遗漏了什么配置?
编辑以说明注释:
创建div时,它是HTMLDivElement的一个实例。
var d = document.createElement('div');
d instanceof HTMLDivElement; // true
d instanceof Element; // true
当获得外部文档和窗口时,这也是正确的:
var frame = document.createElement('iframe');
document.body.appendChild(frame);
var doc2 = frame.contentWindow.document;
var d2
lib.d.ts持有声明:
interface HTMLDivElement extends HTMLElement, ... {}
declare var HTMLDivElement: {
prototype: HTMLDivElement; // additional q: what does this mean?
new(): HTMLDivElement; // q: what does this mean?
}
我猜prototype允许向div添加更多的方法(尽管增强内置js类型并不是过度推荐的),但是对新()的含义猜测较少。
这个宣言是什么意思