草庐IT

Types-TypeScript

全部标签

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

node.js - 使用 TypeScript 导入 Node 模块

我正在尝试让它工作,但我似乎无法在SO上的任何地方找到解决方案。尝试编译此单文件应用程序时:importhttp=require('http')http.createServer(function(req,res){res.writeHead(200,{'Content-Type':'text/plain'});res.end('HelloWorld\n');}).listen(1337,'127.0.0.1');console.log('Serverrunningathttp://127.0.0.1:1337/');使用命令“tscapp.ts--module'commonjs'”我

node.js - 使用 TypeScript 导入 Node 模块

我正在尝试让它工作,但我似乎无法在SO上的任何地方找到解决方案。尝试编译此单文件应用程序时:importhttp=require('http')http.createServer(function(req,res){res.writeHead(200,{'Content-Type':'text/plain'});res.end('HelloWorld\n');}).listen(1337,'127.0.0.1');console.log('Serverrunningathttp://127.0.0.1:1337/');使用命令“tscapp.ts--module'commonjs'”我

javascript - Mongoose typescript 方式...?

尝试在Typescript中实现Mongoose模型。搜了一下谷歌,只发现了一种混合方式(结合JS和TS)。如果没有JS,如何以我相当幼稚的方法实现User类?希望能够在没有包袱的情况下进行IUserModel。import{IUser}from'./user.ts';import{Document,Schema,Model}from'mongoose';//mixinginacoupleofinterfacesinterfaceIUserDocumentextendsIUser,Document{}//mongoose,whyohwhy'[String]'//TODO:investi

javascript - Mongoose typescript 方式...?

尝试在Typescript中实现Mongoose模型。搜了一下谷歌,只发现了一种混合方式(结合JS和TS)。如果没有JS,如何以我相当幼稚的方法实现User类?希望能够在没有包袱的情况下进行IUserModel。import{IUser}from'./user.ts';import{Document,Schema,Model}from'mongoose';//mixinginacoupleofinterfacesinterfaceIUserDocumentextendsIUser,Document{}//mongoose,whyohwhy'[String]'//TODO:investi

node.js - 在编写自定义 TypeScript 定义文件时出现错误 "Module ' name'resolves to an untyped module at..."

我找不到我安装的NodeJS包之一的TypeScript定义@type/{name},所以我尝试为它编写一个d.ts文件,并将文件放在{projectroot}\typings文件夹中。我就是这样做的://Mysourcecode:index.tsimportHelperfrom'node-helper-lib';//Mydefinition:\typings\node-helper-lib.d.tsdeclare....(somethingelse)declaremodule'node-helper-lib'{classHelper{...}export=Helper;}但是,Vis

node.js - 在编写自定义 TypeScript 定义文件时出现错误 "Module ' name'resolves to an untyped module at..."

我找不到我安装的NodeJS包之一的TypeScript定义@type/{name},所以我尝试为它编写一个d.ts文件,并将文件放在{projectroot}\typings文件夹中。我就是这样做的://Mysourcecode:index.tsimportHelperfrom'node-helper-lib';//Mydefinition:\typings\node-helper-lib.d.tsdeclare....(somethingelse)declaremodule'node-helper-lib'{classHelper{...}export=Helper;}但是,Vis

javascript - TypeScript import/as vs import/require?

这个问题在这里已经有了答案:Newes6syntaxforimportingcommonjs/amdmodulesi.e.`importfoo=require('foo')`(6个回答)关闭6年前。我正在使用带有Express/Node.js的TypeScript。对于使用模块,TypeScript手册显示以下语法:importexpress=require('express');而且typescript.d.ts文件也显示:import*asexpressfrom"express";我也搜索了MSDN博客,但没有找到任何东西。截至2016年初,哪一个更正确?如果有的话,两者有什么区别

javascript - TypeScript import/as vs import/require?

这个问题在这里已经有了答案:Newes6syntaxforimportingcommonjs/amdmodulesi.e.`importfoo=require('foo')`(6个回答)关闭6年前。我正在使用带有Express/Node.js的TypeScript。对于使用模块,TypeScript手册显示以下语法:importexpress=require('express');而且typescript.d.ts文件也显示:import*asexpressfrom"express";我也搜索了MSDN博客,但没有找到任何东西。截至2016年初,哪一个更正确?如果有的话,两者有什么区别

node.js - 如何从 typescript 使用 npm 模块?

我正在试一试typescript。它在helloworld阶段运行良好。我现在正在尝试使用npm模块:index.ts=import_=require('lodash')console.log(_.toUpper('Hello,world!'))这不起作用:tscindex.ts->找不到模块“lodash”。(2307)node-tsindex.js->找不到模块'lodash'。(2307)查看typescript文档和在谷歌中没有帮助。其他S/O问题要么没有答案(here和here),要么不相关。元素:typescript1.8最新版是的,lodash已安装npmi--savel