mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 07:13:45 -05:00
Fix 7304: show correct quickinfo on "this" in type position (#8508)
* Show correct quickinfo when using this in type position * Split quickinfo test into smaller files and add test case
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
////function wrapper(wrapped: { (): void; }) { }
|
||||
////class Foo {
|
||||
//// n: number;
|
||||
//// prop1: th/*0*/is;
|
||||
//// public explicitThis(this: this) {
|
||||
//// wrapper(
|
||||
//// function explicitVoid(this: void) {
|
||||
@@ -20,43 +21,9 @@
|
||||
//// console.log(th/*6*/is);
|
||||
//// }
|
||||
////}
|
||||
////class Bar<T> {
|
||||
//// public explicitThis(this: this) {
|
||||
//// console.log(th/*7*/is);
|
||||
//// }
|
||||
//// public explicitClass(this: Bar<T>) {
|
||||
//// console.log(thi/*8*/s);
|
||||
//// }
|
||||
////}
|
||||
////
|
||||
////function implicitAny(x: number): void {
|
||||
//// return th/*9*/is;
|
||||
////}
|
||||
////function explicitVoid(th/*10*/is: void, x: number): void {
|
||||
//// return th/*11*/is;
|
||||
////}
|
||||
////function explicitInterface(th/*12*/is: Restricted): void {
|
||||
//// console.log(thi/*13*/s);
|
||||
////}
|
||||
////function explicitLiteral(th/*14*/is: { n: number }): void {
|
||||
//// console.log(th/*15*/is);
|
||||
////}
|
||||
////
|
||||
////interface ContextualInterface {
|
||||
//// m: number;
|
||||
//// method(this: this, n: number);
|
||||
////}
|
||||
////let o: ContextualInterface = {
|
||||
//// m: 12,
|
||||
//// method(n) {
|
||||
//// let x = this/*16*/.m;
|
||||
//// }
|
||||
////}
|
||||
////interface ContextualInterface2 {
|
||||
//// (this: void, n: number): void;
|
||||
////}
|
||||
////let contextualInterface2: ContextualInterface2 = function (th/*17*/is, n) { }
|
||||
|
||||
goTo.marker('0');
|
||||
verify.quickInfoIs('this: this');
|
||||
goTo.marker('1');
|
||||
verify.quickInfoIs('void');
|
||||
goTo.marker('2');
|
||||
@@ -68,28 +35,4 @@ verify.quickInfoIs('this: Restricted');
|
||||
goTo.marker('5');
|
||||
verify.quickInfoIs('(parameter) this: Foo');
|
||||
goTo.marker('6');
|
||||
verify.quickInfoIs('this: Foo');
|
||||
goTo.marker('7');
|
||||
verify.quickInfoIs('this: this');
|
||||
goTo.marker('8');
|
||||
verify.quickInfoIs('this: Bar<T>');
|
||||
goTo.marker('9');
|
||||
verify.quickInfoIs('any');
|
||||
goTo.marker('10');
|
||||
verify.quickInfoIs('(parameter) this: void');
|
||||
goTo.marker('11');
|
||||
verify.quickInfoIs('void');
|
||||
goTo.marker('12');
|
||||
verify.quickInfoIs('(parameter) this: Restricted');
|
||||
goTo.marker('13');
|
||||
verify.quickInfoIs('this: Restricted');
|
||||
goTo.marker('14');
|
||||
|
||||
verify.quickInfoIs('(parameter) this: {\n n: number;\n}');
|
||||
goTo.marker('15');
|
||||
verify.quickInfoIs('this: {\n n: number;\n}');
|
||||
|
||||
goTo.marker('16');
|
||||
verify.quickInfoIs('this: ContextualInterface');
|
||||
goTo.marker('17');
|
||||
verify.quickInfoIs('(parameter) this: void');
|
||||
verify.quickInfoIs('this: Foo');
|
||||
14
tests/cases/fourslash/quickInfoOnThis2.ts
Normal file
14
tests/cases/fourslash/quickInfoOnThis2.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
////class Bar<T> {
|
||||
//// public explicitThis(this: this) {
|
||||
//// console.log(th/*1*/is);
|
||||
//// }
|
||||
//// public explicitClass(this: Bar<T>) {
|
||||
//// console.log(thi/*2*/s);
|
||||
//// }
|
||||
////}
|
||||
|
||||
goTo.marker('1');
|
||||
verify.quickInfoIs('this: this');
|
||||
goTo.marker('2');
|
||||
verify.quickInfoIs('this: Bar<T>');
|
||||
32
tests/cases/fourslash/quickInfoOnThis3.ts
Normal file
32
tests/cases/fourslash/quickInfoOnThis3.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
////interface Restricted {
|
||||
//// n: number;
|
||||
////}
|
||||
////function implicitAny(x: number): void {
|
||||
//// return th/*1*/is;
|
||||
////}
|
||||
////function explicitVoid(th/*2*/is: void, x: number): void {
|
||||
//// return th/*3*/is;
|
||||
////}
|
||||
////function explicitInterface(th/*4*/is: Restricted): void {
|
||||
//// console.log(thi/*5*/s);
|
||||
////}
|
||||
////function explicitLiteral(th/*6*/is: { n: number }): void {
|
||||
//// console.log(th/*7*/is);
|
||||
////}
|
||||
|
||||
goTo.marker('1');
|
||||
verify.quickInfoIs('any');
|
||||
goTo.marker('2');
|
||||
verify.quickInfoIs('(parameter) this: void');
|
||||
goTo.marker('3');
|
||||
verify.quickInfoIs('void');
|
||||
goTo.marker('4');
|
||||
verify.quickInfoIs('(parameter) this: Restricted');
|
||||
goTo.marker('5');
|
||||
verify.quickInfoIs('this: Restricted');
|
||||
goTo.marker('6');
|
||||
|
||||
verify.quickInfoIs('(parameter) this: {\n n: number;\n}');
|
||||
goTo.marker('7');
|
||||
verify.quickInfoIs('this: {\n n: number;\n}');
|
||||
20
tests/cases/fourslash/quickInfoOnThis4.ts
Normal file
20
tests/cases/fourslash/quickInfoOnThis4.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
////interface ContextualInterface {
|
||||
//// m: number;
|
||||
//// method(this: this, n: number);
|
||||
////}
|
||||
////let o: ContextualInterface = {
|
||||
//// m: 12,
|
||||
//// method(n) {
|
||||
//// let x = this/*1*/.m;
|
||||
//// }
|
||||
////}
|
||||
////interface ContextualInterface2 {
|
||||
//// (this: void, n: number): void;
|
||||
////}
|
||||
////let contextualInterface2: ContextualInterface2 = function (th/*2*/is, n) { }
|
||||
|
||||
goTo.marker('1');
|
||||
verify.quickInfoIs('this: ContextualInterface');
|
||||
goTo.marker('2');
|
||||
verify.quickInfoIs('(parameter) this: void');
|
||||
Reference in New Issue
Block a user