草庐IT

Types-TypeScript

全部标签

node.js - 在 nodejs 中导入 TypeScript 模块

使用typescript在nodejs中导入模块的最佳实践是什么?我来自c#背景,所以我想做这样的事情MyClass.tsmoduleMyNamespace{exportclassMyClass{}}app.ts//somethinglikeusingMyNamespacenewMyNamespace.MyClass();或MyClass.tsexportclassMyClass{}app.tsimportMyClass=module("MyClass")newMyClass();我知道我可以做到这一点并且它会起作用,但是我必须为每个类(class)想出两个名字importMyClas

node.js - Webpack TypeScript module.hot 不存在

我想在TypeScript编写的NodeJS项目中启用WebpackHMR。但是module.hot不可用:@types/webpack-env定义:declarevarmodule:__WebpackModuleApi.Module与@types/node定义冲突:declarevarmodule:NodeModule删除@types/node,解决了问题,但禁用了process:process.env.NODE_ENV==='production'//[ts]Cannotfindname'process' 最佳答案 正如很少有人

node.js - Webpack TypeScript module.hot 不存在

我想在TypeScript编写的NodeJS项目中启用WebpackHMR。但是module.hot不可用:@types/webpack-env定义:declarevarmodule:__WebpackModuleApi.Module与@types/node定义冲突:declarevarmodule:NodeModule删除@types/node,解决了问题,但禁用了process:process.env.NODE_ENV==='production'//[ts]Cannotfindname'process' 最佳答案 正如很少有人

node.js - Typescript mongoose 静态模型方法 "Property does not exist on type"

我目前正在尝试向我的mongoose架构添加一个静态方法,但我找不到它不能以这种方式工作的原因。我的模特:import*asbcryptfrom'bcryptjs';import{Document,Schema,Model,model}from'mongoose';import{IUser}from'../interfaces/IUser';exportinterfaceIUserModelextendsIUser,Document{comparePassword(password:string):boolean;}exportconstuserSchema:Schema=newSch

node.js - Typescript mongoose 静态模型方法 "Property does not exist on type"

我目前正在尝试向我的mongoose架构添加一个静态方法,但我找不到它不能以这种方式工作的原因。我的模特:import*asbcryptfrom'bcryptjs';import{Document,Schema,Model,model}from'mongoose';import{IUser}from'../interfaces/IUser';exportinterfaceIUserModelextendsIUser,Document{comparePassword(password:string):boolean;}exportconstuserSchema:Schema=newSch

node.js - Typescript Node.js 应用程序中的 guid/uuid

我尝试让uuid(v3.0.1)包在Node/Typescript应用程序中工作,但我不确定我应该导入什么以及如何使用它。这是index.d.ts(来自@types/uuidv2.0.29):declarenamespaceuuid{interfaceV1Options{node?:number[];clockseq?:number;msecs?:number|Date;nsecs?:number;}typeV4Options={random:number[]}|{rng:()=>number[];}interfaceUuidStatic{(options?:V4Options):st

node.js - Typescript Node.js 应用程序中的 guid/uuid

我尝试让uuid(v3.0.1)包在Node/Typescript应用程序中工作,但我不确定我应该导入什么以及如何使用它。这是index.d.ts(来自@types/uuidv2.0.29):declarenamespaceuuid{interfaceV1Options{node?:number[];clockseq?:number;msecs?:number|Date;nsecs?:number;}typeV4Options={random:number[]}|{rng:()=>number[];}interfaceUuidStatic{(options?:V4Options):st

node.js - 如何在 npm 中本地安装和运行 Typescript?

我想安装和运行Typescript(即没有全局依赖项)。这是我的package.json文件:{"name":"foo","version":"1.0.0","description":"","main":"index.js","scripts":{"test":"echo\"Error:notestspecified\"&&exit1","tsc":"tsc"},"devDependencies":{"typescript":"^1.8.10"},"author":"","license":"ISC"}然后我运行:npminstallnpmruntsc但是,当我运行第二个命令时,我得

node.js - 如何在 npm 中本地安装和运行 Typescript?

我想安装和运行Typescript(即没有全局依赖项)。这是我的package.json文件:{"name":"foo","version":"1.0.0","description":"","main":"index.js","scripts":{"test":"echo\"Error:notestspecified\"&&exit1","tsc":"tsc"},"devDependencies":{"typescript":"^1.8.10"},"author":"","license":"ISC"}然后我运行:npminstallnpmruntsc但是,当我运行第二个命令时,我得

javascript - 如何修复在 Angular 4 中找不到模块 'typescript'?

我在3周前使用@angular/cli生成了Angular4应用程序。2周后,我尝试使用命令行ngserve运行它,但提示错误如下:Cannotfindmodule'typescript'Error:Cannotfindmodule'typescript'atFunction.Module._resolveFilename(module.js:469:15)atFunction.Module._load(module.js:417:25)atModule.require(module.js:497:17)atrequire(internal/module.js:20:19)atObje