ca00b3248b
* Added --noImplicitThis code fix for functions used as object properties Before trying out all the various possibilities for where these functions could be used, I figured I'd start out with a relatively simple use case to verify this is the right approach. Is it? 😄 Starts on #28964. * Fixed function expression names; included new baselines * Got JSDocs to work, hooray! * Added test for 'any' case of no function uses * Refactored for inferFunctionReferencesFromUsage * Fixed inference bug: undefined references cause parameters to default * Removed dead code comments
35 lines
715 B
TypeScript
35 lines
715 B
TypeScript
/// <reference path='fourslash.ts' />
|
|
|
|
// @allowJs: true
|
|
// @checkJs: true
|
|
// @noImplicitThis: true
|
|
|
|
// @Filename: /consumesType.js
|
|
////function [|returnThisMember|]() {
|
|
//// return this.member;
|
|
////}
|
|
////
|
|
////class Container {
|
|
//// member = "sample";
|
|
//// returnThisMember = returnThisMember;
|
|
////};
|
|
////
|
|
////container.returnThisMember();
|
|
|
|
verify.codeFix({
|
|
description: "Infer 'this' type of 'returnThisMember' from usage",
|
|
index: 0,
|
|
newFileContent: `/**
|
|
* @this {Container}
|
|
*/
|
|
function returnThisMember() {
|
|
return this.member;
|
|
}
|
|
|
|
class Container {
|
|
member = "sample";
|
|
returnThisMember = returnThisMember;
|
|
};
|
|
|
|
container.returnThisMember();`
|
|
});
|