firebase / firebase/firebase-admin-node

Firebase errors are exported as stubs

オープン
#2,582 コメント 1 件 リアクション 1 件 担当者 2 名 @jonathanedey が担当を希望しています GitHub で見る
api: auth api: core
主要言語
TypeScript
スター
1.7k
フォーク
419
平均マージ
3日 10時間
マージ済み PR(30日)
16

説明

### [READ] Step 1: Are you in the right place?

* For issues related to __the code in this repository__ file a Github issue.
* If the issue pertains to Cloud Firestore, read the instructions in the "Firestore issue"
template.
* For general technical questions, post a question on [StackOverflow](http://stackoverflow.com/)
with the firebase tag.
* For general Firebase discussion, use the [firebase-talk](https://groups.google.com/forum/#!forum/firebase-talk)
google group.
* For help troubleshooting your application that does not fall under one
of the above categories, reach out to the personalized
[Firebase support channel](https://firebase.google.com/support/).

### [REQUIRED] Step 2: Describe your environment

* Operating System version: _____
* Firebase SDK version: 12.1.1
* Firebase Product: auth
* Node.js version: _____
* NPM version: _____

### [REQUIRED] Step 3: Describe the problem

#### Steps to reproduce:

The new error types that are exported in 12.1.1 are great and make error handling much easier. However, the TS interfaces are notably lacking constructors - they just extend all the way to Error. The _actual_ implementations take `info: ErrorInfo, message?: string` parameters to set the underlying `code` and `message` properties.

This means that in testing code I'm not able to really take advantage of the new types without casting or playing other type shenanigans in order to set the properties as expected, which significantly limits the usefulness of these newly exported types.

#### Relevant Code:

```
// In a node REPL

> let err = new FirebaseAuthError("test error message")
undefined
> err.code
'auth/undefined'
> err.message
undefined

> let err2 = new FirebaseAuthError({ message: "test error 2", code: "val" })
undefined
> err2.code
'auth/val'
> err2.message
'test error 2'

// In typescript
// Argument of type '{ message: string; code: string; }' is not assignable to parameter of type 'string'.
const error = new FirebaseAuthError({ message: "test error 2", code: "val" });
```

Relates to https://github.com/firebase/firebase-admin-node/pull/2549

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。