* Add helpers that understand constructor functions * getEffectiveConstructSignatures gets construct signatures from type, and call signatures from constructor functions if there are no construct signatures. * getEffectiveConstructSignatureReturnType gets the "JS Class type" for constructor functions, and the return type of signatures for all other declarations. This is a first step toward making constructor functions have construct signatures instead of call signatures, which will also contribute to fixing instantiation of generic constructor functions, which is basically broken right now. Note that the baselines *improve* but, because of the previously mentioned generic problem, are still not correct. Construct signatures for constructor functions and generic constructor functions turns out to be an intertwined problem. * Correct correct originalBaseType And, for now, return anyType for generic constructor functions used as base types. Don't give an incorrect error based on the function's return type, which is usually void. * Add error examples to tests * Add construct signatures instead of getEffective* functions * Fix typo in baseline * Remove pesky newline I thought I got rid of it! * Test of constructor tag on object literal method It doesn't work, and shouldn't in the future, because it's a runtime error.
10 lines
200 B
TypeScript
10 lines
200 B
TypeScript
// @noEmit: true
|
|
// @Filename: example.js
|
|
// @allowJs: true
|
|
// @checkJs: true
|
|
// @noImplicitAny: true
|
|
const obj = {
|
|
/** @constructor */
|
|
Foo() { this.bar = "bar" }
|
|
};
|
|
(new obj.Foo()).bar
|