microsoft / microsoft/TypeScript
Bug: Chained this-intersecting methods don't work from within class
Open
@weswigham is already working on this.
Since Dec 8, 2018.
Bug
Domain: This-Typing
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 3.1.1-insiders.20180926
Search Terms: this chain
Code
class Builder {
private _class: undefined;
withFoo<T>() {
return this as this & { foo: T }
}
withBar<T>() {
return this as this & { bar: T }
}
withFooBar<T>() {
return this.withFoo<T>().withBar<T>();
}
}
let good = new Builder().withFoo<number>().withBar<number>();
let bad = new Builder().withFooBar<number>();
good = bad;
Expected behavior:
good & bad should be identical
Actual behavior:
bad is missing foo
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.
Assessment
This issue has not been assessed yet.