typescript

    1熱度

    1回答

    僅當它嘗試從catch返回值時,纔會發生以下錯誤。希望我在這裏做一個根本錯誤的事情。請給我一個線索。爲什麼我不能從catch返回observable? .TS getMyTopic() { return this.topicSer.getMyTopics().map((res: any) => res.json()).map((res: any) => res = res.categor

    1熱度

    1回答

    我想找到一種方法來在Typescript中動態定義一個常量,但是我開始做這件事是不可能的。 我嘗試這樣做: define(name: string, value: any): boolean { var undef; const name = value; return name == undef; } 我應該撥打: define ('MY_CONST_

    1熱度

    2回答

    我在我的Ionic 3應用程序中顯示一些Firebase數據時遇到問題。下面是我的組件相關的代碼(ABCDEF部分只是針對特定用戶的主要替補): var ref = firebase.database().ref('/profiles/abcdef/'); this.viewProfile = ref.once("value") .then(function(snapshot) {

    4熱度

    2回答

    給出這個簡單的使用對象不存在的鍵:{ id: 'x', value: 1 },在打字稿如果你嘗試這樣做: type foo = { id: string, v: number, }; const bar: foo = { id: 'something', v: 1111 }; // refrencing non existent key if (bar.xyz) {

    1熱度

    1回答

    我正在使用Ionic和Angular開發應用程序,並希望用戶根據需要添加輸入字段。所有教程我在這個題目看都採用了棱角分明的1.x,我採用了棱角分明4. 下面是HTML: <ion-content> <ion-row id="row" ng-repeat= "emailinput of emailinputs"> <ion-col col-3 id="label">

    0熱度

    2回答

    我正在嘗試使用angular2,與角度cli。我創建了一個具有角度cli的應用程序,並帶有新的my-app。現在我想創建一個服務,我需要使用第三方腳本。我看到該腳本已經在node_modules中。 如何在我的服務中包含/導入/注入/使用(不管)該腳本? 我看到一些關於添加到全局腳本的例子。但是如果我只是爲了服務而不需要它,爲什麼我會把它放在全局範圍內呢? my.service.ts import

    2熱度

    2回答

    問題: .filter(audience => audience) 我使用VSCode,我知道爲什麼,因爲它是期待一個布爾值的投擲這個錯誤,我要回一個對象,但這是有效的Javascript,因爲我正在返回一個真值,所以引用將被強制爲真。我可以在配置中更改某些內容以使其正常工作嗎?我已經使它的工作: .filter(audience => Boolean(audience)) 但我寧願避免這

    2熱度

    3回答

    我使用TypeScript作爲Web應用程序的後端,我發現交集類型對於有效的SQL查詢非常有用。基本上,如果我有以下表: User userId: number userEmail: string Post postId: number userId: number (FK) postBody: string 我可以與交叉點型(用戶&郵政),看起來像這樣結束了: {

    1熱度

    1回答

    我有我的客戶端代碼反應本機即.jsx文件,我用gulp來編譯它們。我想轉換我的項目,開始使用打字稿,但一次1個文件。這意味着我需要能夠使用gulp來編譯jsx和ts。 我使用的是下面一飲而盡 - /// <binding AfterBuild='default' /> "use strict"; var gulp = require("gulp"), concat = requir

    17熱度

    2回答

    考慮: enum Colors { Red, Green, Blue } 它transpiles到這一點:這個結果 var Colors; (function (Colors) { Colors[Colors["Red"] = 0] = "Red"; Colors[Colors["Green"] = 1] = "Green"; C