microsoft / microsoft/TypeScript

Isolated declarations does not handle object getters and setters with different types

Aperta
#58,531 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Domain: Declaration Emit Domain: flag: isolatedDeclarations Experience Enhancement
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

🔎 Search Terms
  • isolated declarations
  • object getter
  • object setter
🕗 Version & Regression Information

5.5.0-dev.20240514

⏯ Playground Link

https://www.typescriptlang.org/play/?target=99&isolatedDeclarations=true&ts=5.5.0-dev.20240514#code/KYDwDg9gTgLgBAYwgOwM7wIZwLxwN4BQcxcA5sPAEYAUAlAFxzpQCWyp+RJ3UFArlGRwARMK7EAvgBpxTCnBoA3DABtGzNqVqduEghIDcBAjACeYYHADKMVuwCCKlhlQ4mtzUdCRYiFOkQ3Qm5yeAATOkYbO1JHZ1dg7hJeGAEhUVlpWVR5COU1dxjtRMl9I2NvaHgkNHhLXBKyeQAzSMLNHSTiFLSRMV0Zbhz4VvzGZD4AW0pgKGLMsqA

💻 Code
export const a = {
    get b(): string {
        return ""
    },
    set b(val: string) {
    }
};

type StringAlias = string;
export const c = {
    get d(): StringAlias {
        return ""
    },
    set d(val: string) {
    }
};


export const e = {
    get f(): string {
        return ""
    },
    set f(val: number) {
    }
};
🙁 Actual behavior

TypeScript emits:

export declare const a: {
    b: string;
};
export declare const c: {
    d: string;
};
export declare const e: {
    get f(): string;
    set f(val: number);
};

This is behaviour is not possible to reproduce for isolated declarations emitters, because it requires type comparisons for the types of the setter and getter.

🙂 Expected behavior

One of:

Emit based on syntax, do not collapse a getter/setter pair with the same type to a property

export declare const a: {
    get b(): string;
    set b(val: string);
};
export declare const c: {
    get d(): StringAlias;
    set d(val: string);
};
export declare const e: {
    get f(): string;
    set f(val: number);
};

OR

Error on both c.d and e.f because return type of getter and setter do not match

Additional information about the issue

cc @dragomirtitian

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con l’esempio Playground fornito usando isolatedDeclarations e confronta le dichiarazioni emesse per a, c ed e. L’issue non indica file o test del repository; il lavoro richiederebbe innanzitutto di decidere tra l’emissione di getter/setter basata sulla sintassi e gli errori per i tipi non corrispondenti, quindi di verificare in modo coerente il comportamento scelto.

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

Valutazione

Stack tecnologico
typescript
Ambito
compilers
Tipo di issue
Bug
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.