Tag: 打字稿

(TypeScript)为Parse SDK(浏览器和节点)创buildtypes定义

我正在为Parse Javascript SDK创build一个Typescripttypes定义。 它实际上是完整的。 该定义适用于浏览和云代码,但不适用于Node。 使用parsing与客户端和服务器端JavaScript 浏览示例: var GameScore = Parse.Object.extend("GameScore"); 节点示例: var Parse = require('parse').Parse; var GameScore = Parse.Object.extend("GameScore"); Psueduetypes定义 declare module Parse { interface FacebookUtils { init(options?: any); } class Object { constructor(attributes?: any, options?: any); } module Cloud { interface FunctionResponse { success?: (response: HttpResponse) => void; error?: (response: HttpResponse) => void; […]

从客户端传递给nodeJS时,string转换为Object

我正在使用yeoman angular-fullstack来生成我的项目。 所以客户端是angularJs(typeScript),后端是nodeJs。 问题是我有一个variables,当我打印到控制台,我得到一个非常长的string,(如果你需要知道它从googleplacesapi photo_reference)。 而当我通过它的http.get传递给nodeJS api,并将其打印到日志中,我得到响应Object对象。 MainController for (var photo of response.data.result.photos) { this.getImages(photo); console.log(photo.photo_reference); } getImages(photo_reference: string): void{ this.$http.get('/api/image/' + photo_reference).then((response) => { }); } 的NodeJS export function show(req, res) { console.log("photoreference:" + req.params.photoreference);

我的打印机编译器有什么问题? `tsc –version`什么都不返回

在Linux Mint中,我安装了节点并用它来安装打字稿。 使用工作打字稿安装时, tsc –version应返回版本号。 在我的情况下,没有任何返回。 当我运行which tsc ,结果是/usr/local/bin/tsc 。 当我运行cat /usr/local/bin/tsc ,结果是: #!/usr/bin/env node require('../lib/tsc.js') 当我运行find /usr/local -name 'tsc*' ,结果是: /usr/local/bin/tsc /usr/local/lib/node_modules/typescript/bin/tsc /usr/local/lib/node_modules/typescript/lib/tsc.js 这看起来正确吗? 如果是这样的话,那么还有什么想法呢? 注意我也尝试运行/usr/local/lib/node_modules/typescript/bin/tsc –version并得到了相同的结果,即没有。

如何在打字稿中加载电子模块

我尝试从打字稿中的电子获得ipcRenderer模块,将信息从当前组件发送到核心,并将信息返回窗口(电子铬浏览器)。 我得到的是通过将ts代码转码为ES5而出现“模块未find”的错误。 const ipc = require('electron')。ipcRenderer;` 更新:错误是在“找不到模块”和这个之间切换: ERROR in ./~/electron/index.js Module build failed: Error: ENOENT, open '/…/node_modules/electron/index.js' @ ./app/components/search/search.ts 12:10-29 这是从现在的电子api 。 我也尝试使用打字机的input语法,但结果是一样的。 比我试图在ES5文件中使用electron.ipcRenderer模块,直接在html文件中加载/链接。 那里工作。 为什么?

用于file upload的Angular2服务器端侦听器

在Angular2 CLI项目中,我finnaly从Vaadin实现了这个上传button。 button用户界面的作品,但我不知道如何实际上使任何地方上传文件。 我一直在寻找解决scheme, 快速的服务器 ,侦听file upload, 多function一体机或节点服务器 ,我真的不知道如何编写这样的服务器,放在哪里,如何启动它,如何访问它等。认为像file upload这样简单的事情应该更容易实现,但似乎并非如此。 什么是一个简单的解决scheme来实现边Angular2为了使button实际上传文件的地方,所以我可以下载它们以后?

如何在没有types定义的情况下在Typescript中导入节点模块?

当我尝试像这样在Typescript中导入node.js模块时: import co = require('co'); import co from 'co'; 不提供types定义,两行都报告相同的错误: error TS2307: Cannot find module 'co'. 如何正确导入?

要求使用TypeScript,SystemJS和Electron的nodejs“child_process”

我正在研究一个简单的nodejs 电子 (以前称为primefaces壳)项目。 我正在使用angular 2编写它,使用项目相同的项目设置,他们build议在typescript的文档中: TSC: { "compilerOptions": { "target": "es5", "module": "system", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "removeComments": false, "noImplicitAny": false }, "exclude": [ "node_modules", "typings/main", "typings/main.d.ts" ] } 我需要运行一个命令,我发现我可以用节点“child_process”来完成。 无论如何我无法find“导入”或“要求”,而从node.d.ts文件中使用它的types。 我在node.d.ts文件中find了适合我需要的“child_process”接口,这就是它在node.d.ts文件中的样子: declare module "child_process" { import * as events from "events"; import * as stream from "stream"; export interface ChildProcess […]

如何在TypeScript中使用Node`http`模块

我需要在TypeScript和Node中编写一个服务器。 我从DefinitelyTyped存储库下载了Node 我创build了我的打字稿文件 导入定义 尝试使用它 结果是: /// <reference path="definitions/commonjs.d.ts" /> /// <reference path="definitions/node.d.ts" /> var http = require("http"); namespace MyProj { export class Server { public run() { var server = http.createServer(); // TypeScript does not recognize 'http' } } } 但我不明白我怎么可以参考http模块。 我在哪里可以findtypes? 在定义文件中,我很难识别这些信息。

找不到名称“控制台”。 这可能是什么原因?

以下片段在LINE 4处显示打字稿错误: import {Message} from './class/message'; function sendPayload(payload : Object) : any{ let message = new Message(payload); console.log(message); // LINE 4 } 错误说: [ts] Cannot find name 'console'. 这可能是什么原因? 为什么找不到对象console ?

Visual Studio 2015 NodeJS / Typescript覆盖节点启动文件

我不断收到以下错误: Error Code: TS5055 Cannot write file C:/project/dir/server.js' because it would overwrite input file. Project: TypeScript/JavaScript Virtual Projects 我什至尝试改变我的入口文件nodeserver.js和一段时间后,我得到了同样的错误: Error Code: TS5055 Cannot write file C:/project/dir/nodeserver.js' because it would overwrite input file. Project: TypeScript/JavaScript Virtual Projects 我怎样才能找出什么组件试图覆盖它? 我注意到文件的BuildAction设置为Compile和“发布”为true。 这可能是原因吗? closuresCompile .js文件的含义是什么? 我会不会得到任何错误检查? configuration文件 我的tsconfig.json { "compileOnSave": true, "compilerOptions": { "target": "es6", "module": "commonjs", "moduleResolution": "node", […]