![](/img/trans.png)
[英]Can I wrap two different host listeners in a single function in angular 2
我需要將 2 個不同的主機偵聽器包裝在一個 function 中,這樣我就可以在需要偵聽器時調用 function。 現在我需要將它包裝在一個 function 中,如下所示,並且可以在需要時調用它 function ...
[英]Can I wrap two different host listeners in a single function in angular 2
我需要將 2 個不同的主機偵聽器包裝在一個 function 中,這樣我就可以在需要偵聽器時調用 function。 現在我需要將它包裝在一個 function 中,如下所示,並且可以在需要時調用它 function ...
[英]What for incompatibility between babel-proposal-decorators and typescript-decorator?
我最近在https://github.com/MOCHI-inc-JAPAN/class-fixtures-factory重寫了 CyriacBr/class-fixtures-factory並更新了庫版本。 我成功地在 ts-jest 環境中運行它,但是切換 jest-expo,不起作用。 我懷 ...
[英]TS. Enumerate the decorators
我有一個問題 - 我正在嘗試編寫自己的 Injectable 實現,我需要知道我的 Class 中是否有特定的裝飾器。 我如何枚舉 class 的所有裝飾器? 例如,我有以下代碼。 我只需要知道我是否在 MyClass 中將“myDecorator”作為裝飾器 也許,我可以使用 Reflect-AP ...
[英]Dynamically create class definition including decorator with TypeScript
是否可以使用如下的裝飾器動態生成 class 定義? (代碼實際上不起作用,但顯示了我想要實現的目標) *此代碼包含TypeORM的裝飾器,但題意不涉及庫知識。 ...
[英]How to change the type of an @Input variable with an other chained decorator
我想將@Input 轉換為 stream。 這就是我的意思: 奇跡般有效。 現在我可以在我的代碼中到處使用這個 stream。 但我想知道是否有辦法簡化這一點,例如@Decorator: 更好 但是現在 angular 開始抱怨number[]> vs Observable<number ...
[英]Unable to access value using Property decorator in typescript
我正在寫一個Vanilla Typescript程序,如下圖 我得到 output 作為Class 目標和道具名稱是:undefined,property1而不是Class 目標和道具名稱是:Siddu Rocks,property1 為什么我將屬性值設為未定義,這里有什么遺漏嗎? 我嘗試檢查多個博 ...
[英]Eslint wong error `is defined but never used` warning in NestJs for all decorators
我正在為一個項目使用 NestJs 框架。 今天發現 EsLint 發現了 587 個錯誤的問題。 所有裝飾器都會產生這個錯誤:warning 'IsBoolean' is defined but never used @typescript-eslint/no-unused-vars ...
[英]How do I implement OnInit without getting error: Class is using Angular features but is not decorated. Please add an explicit Angular decorator
我想擺脫上面的錯誤。 它在使用 npm i 重新安裝依賴項后開始出現。 我嘗試刪除“implements onInit”並且它消失了所以問題與它有關。 但我想使用“實現 onInit”而不會出現此錯誤。 我懷疑它也與 typescript 版本(我升級到最新版本)有關。 更新:當然,我在 class ...
[英]Manually register a typeorm EventSubscriber in NestJS without specifying it in the configuration file
在 NestJS 中,我擴展了 class EntitySubscriberInterface 來創建一個通用的 EventSubscriber。 我的目標是每次在數據庫中插入某些內容時捕獲所有 typeorm 存儲庫事件“beforeInsert”(應該為所有實體觸發)。 此代碼有效,因為該文件保 ...
[英]@UseInterceptors ignores @Expose and not working properly
我創建了一個自定義裝飾器和 SerializeInterceptor class: 我在 controller 中使用它,例如: 這是返回的 JSON: 我的問題是在ReviewDto文件中我將@Expose()裝飾器設置為developerComment和authorName並且它不起作用。 另外 ...
[英]Typescript Decorator on method; get method in decorator
我正在嘗試制作一個可以: 取一個參數將上面的方法存儲為可調用的 function Map 可調用的 function 帶有裝飾器采用的參數。 這是我嘗試過的: 但是,它說 func 不是 function。 它將其存儲為 Bar class。 如何將該方法存儲為 function? ...
[英]How add method decorator
我想在 angular 中創建方法裝飾,我可以在其中傳遞參數,它將覆蓋結果。 例如,假設我有計算 typescript 文件,如下所示。 我有上面的“乘法”方法裝飾器,當我調用console.log(new Calculation().addOne(2))時,我將參數值作為 2 傳遞,它應該返回 ( ...
[英]Can you use super class methods as decorator methods - Typescript
如果我能夠實現這一點,我將能夠為我正在從事的項目設計一個非常容易擴展的裝飾器工廠。 基本上,我希望能夠使用超類的方法作為子類屬性的裝飾器。 這通常是裝飾器的工作方式: 然后是裝飾器 function: 但是,我不想為裝飾器定義單獨的 function,而是希望裝飾器 function 來自超級 c ...
[英]Property not available after applying decorator in typescript
我只想添加裝飾器而不影響實例創建。 這是示例代碼 創建 new User() 僅提供 { username: 'dany' } 密碼在新實例中不可用。 為什么密碼不是用戶的一部分? ...
[英]TS decorator to wrap function definition in try catch
是否可以使用 TS 裝飾器將 function 定義包裝到 try-catch 塊中。 我不想在每個 function 中都使用 try-catch,所以我想也許裝飾器可以提供幫助。 例如 這樣的事情可以在裝飾器中完成,這樣它也可以用於其他功能。 ...
[英]PropertyDescriptor undefined when using TS decorator
TS 裝飾器 結果: 使用的函數 我不知道為什么它在裝飾器中記錄未定義。 ...
[英]How to pass a value from controllers to service methods with decorator in nestjs?
我有一個 controller 如下: @Controller() class UserController { @Post("/order") @ApiBearerAuth() async createOrder(@Body() order: Order, @GetHeaderItem("H ...
[英]The correct way to use decorators when logging services in Angular
我有兩種服務,一種是 Auth 服務,另一種是 Analytics 服務,它們存在於不同的庫中。 分析服務用於進行事件記錄。 我可以使用它來記錄auth.service的一種明顯方法是在 auth 服務中注入分析服務,但我不想使用這種方法,我想使用裝飾器策略。 實現這一目標的正確方法是什么? 是否可 ...
[英]Decorator setter is never called
我正在嘗試在打字稿中編寫一個lazyLoad 裝飾器,我想出了以下內容 function LazyLoad(target: any, propertyKey: PropertyKey, descriptor: PropertyDescriptor) { // eslint-disable-n ...
[英]Enumerations use in Angular HTML
我有一個枚舉,想在 Angular 13 組件中使用它。 枚舉: TS: HTML: 結果: 沙箱在這里 但是,我不想在組件中創建與該枚舉對應的屬性... 它對我有任何意義,因為沒有要保留的特定信息,我想使用 HTML 中的大寫字母作為普通枚舉。 所以我嘗試了裝飾器 ...