googleapis / googleapis/google-api-nodejs-client

Improve 'historyTypes' typing

Aperta
#3,178 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
api: gmail priority: p3 type: feature request
Lingua principale
TypeScript
Stelle
12.2k
Fork
2k
Merge medio
1g 9h
PR unite (30g)
24

Descrizione

It seems that the `historyTypes` property on the [Params$Resource$Users$History$List](https://github.com/googleapis/google-api-nodejs-client/blob/main/src/apis/gmail/v1.ts#LL2583C3-L2583C54) interface could be improved by giving users a list of valid values. In its current implementation, any list of strings is valid.
My proposed solution would look something like [this](https://www.typescriptlang.org/play?#code/MYewdgzgLgBAtgUwhAhgcwQQQCbYdmAXhgCJFl0td8SYAoUSWc1DAEQQBsEp8jSWlDt17YSDcNBicUAIy448BYiRnzOimhKbS5XAEoI4IAG58Vag0dNa6dKAE8ADghgAJAJbQQAJwcAVZyR+TB8fFAcAHjoYWJhHFxAAM3gkViolGAAfeKDk1Ip2Lh4+HISEfMsNagIyvJSqw2MzbDoAPgBuO0YpAAsvKF8AoIgALncBocCXCH4AbVU9aqUSAF07OiA):

```ts
const messageAdded = "messageAdded"
const messageDeleted = "messageDeleted"
const labelAdded = "labelAdded"
const labelRemoved = "labelRemoved"

type HistoryTypes = Array<
typeof messageAdded | typeof messageDeleted | typeof labelAdded | typeof labelRemoved
>;

const historyTypes: HistoryTypes = ["labelAdded"]
```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start in src/apis/gmail/v1.ts at the Params$Resource$Users$History$List interface and inspect the current historyTypes declaration. Compare it with the four valid values listed in the issue, then verify that the resulting type accepts those values and rejects arbitrary strings.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
nodejs, typescript
Ambito
api
Tipo di issue
Funzionalità
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.