microsoft / microsoft/TypeScript
Isolated declarations does not handle object getters and setters with different types
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
🔎 Search Terms
- isolated declarations
- object getter
- object setter
🕗 Version & Regression Information
5.5.0-dev.20240514
⏯ Playground Link
💻 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided Playground example using isolatedDeclarations and compare the emitted declarations for a, c, and e. The issue names no repository files or tests; work would first require deciding between syntax-based getter/setter emission and errors for mismatched types, then verifying the chosen behavior consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100