编译位于typescript文件中的以下代码时出现错误:
parent.$(mySelector)
这里我在$符号上遇到了一个错误,这个符号对于typescript编译器来说是未知的。通过定义文件引用Jquery。我可以做些什么来仍然能够使用这种编写代码的方法呢?
我遇到的正确错误如下:
The property '$' does not exist on value of type 'Window'
我试图使用用TypeScript编写Node.js服务器,但在将fs.readFile转换为rxjs形式时遇到了错误。我希望下面的代码可以在TypeScript中工作
// This is a JavaScript example from the official documentation. It should
// also work at the TypeScript envrionment.
import * as fs from 'fs';
import { Observable } from 'rxjs';
let readFileAsObse
为什么TypeScript编译器没有将下面的情况标记为错误,有什么具体原因吗?
myFunction(len: number) {
var len: number = 5; // re-definition of local variable (name clash)
}
另一个:
myFunction() {
var b: number = a; // variable a is accessed before it is declared/initialized
var a: number = 5;
}
在将Javascript转换为TypeSc
在新计算机上设置项目并遇到TypeScript版本控制问题。我试过了:
npm install -g typescript
npm install typescript
npm install -g typescript@2.1.6
npm install -g typescript@2.0.10
但每次我尝试使用以下命令检查版本时:
tsc -v
我得到以下错误:
The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
我有一个简单的对象,有两个字段name和age,最初它们被定义为未定义的,稍后在代码中将赋值 const s={
name:undefined,
age:undefined
}
s.name="Test" //error 当我尝试为我的属性赋值时,它会出现typescript错误 Type '"Test"' is not assignable to type 'undefined'. 有人能解释为什么我在typescript中遇到这个错误以及如何修复它吗?
我一直试图将Vue.js与TypeScript结合使用,并偶然遇到了。
在这里,我遇到了一些问题,在从TypeScript导入Vue单组件文件时遇到了错误。我正在使用代码。请参阅下面的错误。
main.ts:
// The Vue build version to load with the 'import' command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import * as Vue from 'vue'
import App f
我在弄清楚如何在typescript 4.1中使用react-i18next时遇到了麻烦。
根据文档,我应该能够做到:
const { t } = useTranslation();
return <h1>{t('title')}</h1>
但是,对t调用会出现错误:
No overload matches this call: Argument of type 'string' is not assignable to parameter of type 'never'.
工作原理是使用以下两种方法之一:
useTran
我安装了最新的.NET Core。在Visual (非VS代码)中,我选择了ASP.NET核心反应模板。该网站运行良好。太棒了。但是当我尝试使用TypeScript时,我遇到了一些问题:
当我添加一个.tsx文件时,我会得到一个编译错误。Cannot use JSX unless the '--jsx' flag is provided.
当我试图通过在命令行中输入npm test来使用Jest时,它会运行测试。好的。但是,当我将一个测试放入一个TypeScript文件时,我会得到像Cannot find name expect这样的编译错误。当我尝试使用时,我开始遇到
我已经将eslint添加到我的nestjs 7项目中,并与未使用的vars错误混淆。 我在模块、生命周期方法和服务上遇到错误。也得到了类型的错误 import { Controller, Get } from '@nestjs/common';
import {
HealthCheck,
HealthCheckService, ---> got here the the error
MongooseHealthIndicator, ---> got here the the error
} from '@nestjs/terminus
我正在尝试在Typescript中使用promises和Firebase,使用这个定义文件:,但我在尝试使用promises:Supplied parameters do not match any signature of call target.时遇到这个错误,我猜这是因为定义文件不支持Promises,对吗?我刚刚开始了解Typescript,谁能告诉我如何更改定义文件以支持promises?
我是TypeScript新手,当包含jquery.d.ts在构建代码时遇到许多语法错误时,我使用的是VS EXPRESS2012。为了包含jQuery定义,我使用了以下代码:
/// <reference path="./jquery.d.ts" />
仅从定义文件中我就得到了很多错误-例如:
Error 109 Index signature parameter type must be 'string' or 'number'. D:/Able/TypeScript/HelloWorld/HelloWorld/jquer
当用户单击重置按钮时,我在尝试重置表单时遇到打字错误。 onClearSearchFormClicked() {
this.$refs.searchForm.reset();
} 197:27 Property 'reset' does not exist on type 'Element | Element[] | Vue | Vue[]'.
Property 'reset' does not exist on type 'Element'.
196 | onClearSearchFormClicked()
向实际上已经存在的类型记录中添加函数的最佳方法是什么?在我的例子中,这是Node.getAttribute(),它实际上是内置于浏览器的,但还没有被TypeScript识别。It错误:Cannot find property 'getAttribute' on type 'Node'.
在我的例子中,我遇到了执行以下操作时出现的错误:
var xmlDocument = new DOMParser().parseFromString(xmlString, "text/xml"),
rootfile = xmlDocument.get