我安装了最新的NVM,并使用它来安装NodeJS (macOS)。一切都很好,NodeJS正常运行。但是,当我开始VS代码时,出现了以下消息:
无法安装JavaScript语言功能的键入文件。请确保在用户设置中安装或配置“typescript.npm”
因此,我试图从VS代码团队中找到更多的官方信息。他们说要在typescript.npm设置中插入npm可执行文件的路径。
我使用$ which npm查找npm目录:
/Users/myusername/.nvm/versions/node/v8.3.0/bin/npm
但是那里没有可执行文件。我还试图将这个地址插入到VSCode ty
在我的TypeScript 2.0代码中(在Visual 2015中),我有:
var lang = navigator.language
? navigator.language
: navigator.systemLanguage;
有了这个,我得到了一个错误:
Build:Property 'systemLanguage' does not exist on type 'Navigator'.
但是,如果我将它添加到我的一个d.ts文件中:
interface Navigator {
systemLanguage
在新计算机上设置项目并遇到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
我有一组奇怪的“本地”npm模块,它们使用TypeScript并相互依赖,类似于:
A -> B, C
B -> C
C -> D
我需要运行npm install,并将所有的TypeScript编译得井然有序,否则它将找不到合适的东西。我的印象是,我应该使用prepublish脚本来处理TypeScript编译,但它似乎并没有对本地依赖项的prepublish请求进行级联。
如何使用prepublish脚本设置一组本地模块,使它们在运行npm install时都能得到适当的解析
另一种表达我想问的问题的方法是:如何维护多个本地节点模块并同时修改它们?模块之间存在不同的依赖
我正在尝试使用
@tabler/angular-core
@tabler/angular-ui
@tabler/angular-styles
@tabler/angular-forms
在npm安装了所有这些包并运行ng serve之后,我得到了错误:
Argument of type '{ read: typeof ViewContainerRef; }' is not assignable to parameter of type '{ read?: any; static: boolean; }'.
Property 'static'
我正在使用编写一个,它允许您在本地开发编译成Google Scripts的TypeScript文件。
我通过运行npm i -S @types/google-apps-script导入了谷歌脚本类型定义,并且我的集成开发环境(VS代码)似乎确实理解谷歌脚本类型。然而,我似乎不能用这些类型定义来注释我的变量。例如,
let ss: Spreadsheet;
ss = SpreadsheetApp.getActive();
可以用这些导入的类型定义来注释我的代码吗?
我不知道如何恰当地描述这一点,所以让我举个例子。我有一个库,它返回一个函数作为构造函数:
var userTemplate = lib.User;
var user = new userTemplate();
我希望将此userTemplate强类型化为一个类,因为我知道它将具有哪些属性。我还希望能够在应用程序的其他部分执行var user = new userTemplate()之类的操作,并使user对象具有某种已知类型。
我觉得我需要在这里使用环境类声明,但我不确定如何将环境声明指定为对实际构建器的引用?
例如,我想要这样的内容:
export class Storage{
in
我安装了Visual代码,并希望使用NodeJS编写TypeScript代码。因此,我创建了非常基本的应用程序,并得到了一个错误,即:
Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.ts(2580)
执行上述npm命令不能解决问题。我已经失去了我所关注、阅读过的链接的墙,或者不适用于我,没有解决问题,已经过时等等:
这个离我最近的是:
我运行了以下命令:
npm i --save-dev @type
我有一段时间一直试图在我的NextJS项目中使用打字本.我认为从打字本开始是最困难的,但不是:它的安装更加复杂。
我遵循了上所说的(创建一个新项目)。
以下是我所做的事情:
npx create-next-app --ts
cd test-nextts
npm run dev
这是我在npm run dev上遇到的错误
> test-nextts@0.1.0 dev
> next dev
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
It looks like you're tryin
我在一台新计算机上尝试运行npx create-react-app myapp,但收到此错误。以前从来没有过这个,看起来它缺少es-lint包?
$ npx create-react-app my-app
npx: installed 99 in 4.157s
Creating a new React app in C:\Users\Name\Documents\demos\my-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scri
我有一个这样的TypeScript接口: export interface Foo {
bar: string
} 这将编译成一个空的.js文件。因此,当在ES6节点模块中使用TypeScript接口时,我会得到以下错误: TypeError: Class extends value undefined is not a function or null 解决方法是创建一个类 export class BaseFoo {
bar: string
} 现在,我可以在ES6中使用BaseFoo,而不会出现上述错误。因此,在TypeScript中使用ES6互操作不可能只有接口,或者有没有比
正如我从SO中学到的,节点的依赖关系不会自动安装,因为npm 3。
npm WARN eslint-config-react-app@5.0.2 requires a peer of @typescript-eslint/eslint-plugin@2.x but none was installed.
npm WARN eslint-config-react-app@5.0.2 requires a peer of @typescript-eslint/parser@2.x but none was installed.
npm WARN eslint-config-react-app@5.
假设我有两个类(或更多)。一个作为数据库实体,一个作为json约束。因为数据库实体将属性设置为外键,因此属性是对象。但在json的情况下,该属性只是一个字符串类型。
interface A {
title: string
catalogue: string
}
数据库实体类需要目录作为对象,因为CatObj包含其他信息,如id、名称等。
class AEntity implements A {
public title: string
public catalogue: CatObj
}
json格式
const aJson: A = {
title: