Tag: 打字稿

npm模块发布后缺less文件

作为参考,回购是https://github.com/microsoftly/luis-response-builder 。 节点模块文件使用tsc生成并输出到dist文件夹。 我有一个prepublishOnly步骤,删除dist文件夹,运行tsc,然后运行testing针对transpiled js。 当我发布的testing通过罚款。 问题是,当我在其他地方安装项目时,dist文件夹只包含dist / src / index.jspath的文件。 我不能为了我的生活找出为什么安装时文件丢失,但没有发布。

离子2菜单转换

我遵循离子2的菜单文档,我想显示这样的菜单: 所以菜单显示在内容页面下方,菜单button仍然显示。 但是当我运行我的应用程序,我得到这个: 菜单显示在内容页面上方,button消失! 这里是app.html代码: <ion-split-pane> <ion-menu side="left" id="loggedInMenu" [content]="content"> <ion-header> <ion-toolbar> <ion-title>Menu</ion-title> </ion-toolbar> </ion-header> <ion-content> <ion-list> <button ion-item menuClose="loggedInMenu" *ngFor="let p of appPages" (click)="openPage(p)"> <ion-icon item-start [name]="p.icon" [color]="isActive(p)" ></ion-icon> {{p.title}} </button> </ion-list> </ion-content> </ion-menu> <!– main navigation –> <ion-nav [root]="rootPage" #content swipeBackEnabled="false" main name="app"></ion-nav> </ion-split-pane> app.componenent.ts: import { Component, ViewChild } from '@angular/core'; import […]

在angular度prod构build期间的Javascript内存不足

我在为Windows 4中的angular 4项目生成prod时遇到以下错误 :92%块资产优化<—最后几个GC —> [2608:000002518B1007B0] 578653 ms:标记扫描1400.7(1534.2) – > 1400.7(1502.2)MB,1409.9 / 0.0 ms不得已[2608:000002518B1007B0] 579952 ms:标记扫描1400.7(1502.2) – > 1400.7(1501.2) MB,1298.6 / 0.0 ms最后的手段 <— JS stacktrace —> ==== JS堆栈跟踪========================================= 安全上下文:0000003DF7DA66A1 1:DoJoin(又名DoJoin)[native array.js:〜97] [pc = 0000032E01B053FC](this = 000001F775C02311,q = 0000010002582251,r = 4,F = 000001F775C023B1,B = 000001F775C02471,A = 000001F775C02421) 2:Join(aka Join)[native array.js:〜122] [pc = 0000032E01E5AD22](this = 000001F775C02311,q […]

运行navalia示例的打字稿错误

我试图从https://github.com/joelgriffith/navalia运行这个例子,但为了我的光,我不能没有错误地工作: navaliatest.ts /// <reference path="typings.d.ts" /> import { Chrome } from 'navalia'; const chrome = new Chrome(); async function buyItOnAmazon() { const url = await chrome.goto('https://amazon.com'); const typed = await chrome.type('input', 'Kindle'); const clicked = await chrome.click('.nav-search-submit input'); chrome.done(); console.log(url, typed, clicked); // 'https://www.amazon.com/', true, true } buyItOnAmazon(); tsconfig.json { "files": [ "navaliatest.ts" ], "compilerOptions": […]

在后端,响应和反应本机客户端之间共享打字稿代码

我已经开始将我的项目转换为打字稿,同时我决定改进node.js后端之间的代码重用,响应Web客户端和反应本地移动客户端。 这是我的项目结构: ├ commons (code shared between backend and frontend, mostly type definitions and utils ├ clients (code shared between web and mobile clients, depends on commons: containers, utils, forms… ) ├ backend (express server, depends on commons) ├ web (create-react-app, not ejected, no SSR needed, depends on clients) ├ mobile (react-native client, depends on […]

string原型在浏览器中工作,但不在节​​点中

节点: 8.1.0 我有以下原型: String.prototype.toSlug = function () { return (<string>this) .trim() .toLowerCase() .replace(/\s+/g, '-') .replace(/[^\w\-]+/g, '') .replace(/\-\-+/g, '-') .replace(/^-+/, '') .replace(/-+$/, '') } 当我使用它时,像这样: // Mongoose Database Model: let project = new ProjectModel project.slug = title.toSlug() 它似乎不能正常工作。 它所做的只是删除第一个空间,并添加一个破折号,如下所示: // Original: "Bed Time Stories" // Outputs: "BedTime-Stories" // Expected: "bed-time-stories" 正如你所看到的,它甚至没有将string转换为小写字母。 然而,当我在jsfiddletesting这个,它创build正确的输出string。 这是什么原因造成的?

声明与打印机自定义接口合并

我正在寻找添加一个用户属性的express.Requesttypes,使得req.user将是我的自定义typesIUser。 我读了声明合并是要走的路,所以我创build了一个custom.d.ts文件 declare namespace Express { export interface Request { user?: IUser; } } 尽pipe打字稿现在允许我使用req.user,但它被定义为键入any 。 在我的types文件中导入IUser并没有帮助,因为它只是使打字机变得更糟,现在根本不能识别req.user。 我的打字怎样才能被IDE视为IUser?

有没有办法检查当前的输出是否input打字稿?

在commonjs(节点)我可以这样做: module.exports = {…} if (module.parent) {…} 打字稿中有类似的东西吗? 我正在编写一个Web应用程序,它将允许我在testing期间不绑定端口。

如何在打字稿中重载Node.js Writable end方法

我创build了一个从Node.jsstream库类扩展的类,在这个类中做了一些特殊的事情。 import * as stream from 'stream'; export class PipeWritable extends stream.Writable { … public end(): void; public end(chunk: any, cb?: Function): void; public end(chunk: any, encoding?: string, cb?: Function): void { super.end(); } } 这导致错误: error TS2394: Overload signature is not compatible with function implementation 重载方法的参数结构从@types/node/index.d.ts 1:1复制。 我知道打字稿不支持方法重载,但是如果你声明了模块,你可以这样做,就像在Node.js模块stream中看到的那样: declare module "stream" { export class […]

使用Http Post的Typescript&Angular问题新手

我是Angular和Typescript的新手,我尝试创build一个简单的login页面。 我在用户按下“login”button时调用的打字稿中创build了一个服务。 包含用户名和密码的文本框与模型绑定正确,但是当我将请求发送到用C#编写的后端时,它不会触及断点,我怀疑这是由于消息在线路上发送的格式。 因此,使用PostMan ,我可以调用服务,并获得一个access_token当在PostMan请求导出到代码时,这是PostMan变体的样子: var request = require("request"); var options = { method: 'POST', url: 'http://localhost:8081/login', headers: { 'postman-token': '34dd4d0f-ff16-db4f-ebae-dab945729410', 'cache-control': 'no-cache', 'content-type': 'application/x-www-form-urlencoded' }, form: { username: 'test', password: 'test', grant_type: 'password' } }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); 这是我的手稿代码 login(userName: string, password:string) : Observable<boolean> […]