You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Invalid property access in quick info relating to type arguments #4616
Expected: A in MixinCtor<A>
Actual: The language service tries to get length off of undefined, crashes.
Description:
getQuickInfoAtPosition('C:\Users\drosen\AppData\Local\Temp\~vsBEB5.ts', 61)
Message:
StackTrace:
TypeError: Unable to get property 'length' of undefined or null reference
at getSignatureFromDeclaration (:16096:33)
at getSymbolDisplayPartsDocumentationAndSymbolKind (:44944:25)
at getQuickInfoAtPosition (:45136:13)
at Anonymous function (:48843:17)
at simpleForwardCall (:48683:9)
at forwardJSONCall (:48699:13)
at forwardJSONCall (:48745:13)
at getQuickInfoAtPosition (:48842:13)
Since all of those are 'isFunctionLike`, and are returned by getContainingFunction but are not the node on which that type parameter lies. (I believe)
Here's a comprehensive set of tests exposing the issues:
///<reference path="fourslash.ts" />//// type Ctor<AA> = new () => A/*1*/A;//// type MixinCtor<AA> = new () => AA & { constructor: MixinCtor<A/*2*/A> };//// type NestedCtor<AA> = new() => AA & (new () => AA & { constructor: NestedCtor<A/*3*/A> });//// type Method<AA> = { method(): A/*4*/A };//// type Construct<AA> = { new(): A/*5*/A };//// type Call<AA> = { (): A/*6*/A };//// type Index<AA> = {[foo: string]: A/*7*/A};//// type GenericMethod<AA> = { method<BB>(): A/*8*/A & B/*9*/B }goTo.marker('1');verify.quickInfoIs('(type parameter) AA in type Ctor<AA>');goTo.marker('2');verify.quickInfoIs('(type parameter) AA in type MixinCtor<AA>');goTo.marker('3');verify.quickInfoIs('(type parameter) AA in type NestedCtor<AA>');goTo.marker('4');verify.quickInfoIs('(type parameter) AA in type Method<AA>');goTo.marker('5');verify.quickInfoIs('(type parameter) AA in type Construct<AA>');goTo.marker('6');verify.quickInfoIs('(type parameter) AA in type Call<AA>');goTo.marker('7');verify.quickInfoIs('(type parameter) AA in type Index<AA>');goTo.marker('8');verify.quickInfoIs('(type parameter) AA in type GenericMethod<AA>');goTo.marker('9');verify.quickInfoIs('(type parameter) BB in method<BB>(): AA & BB');
The issue is on ~line 4228 of services.ts. We call getContainingFunction(location) when what we really want is something else. What we want to know if the type parameter is derived from its enclosing function or its enclosing type alias, and the presence of a containing function-like node is not enough information to determine that.
I also advise checking against the quick infos for this, in additon to those in the test above:
typeNesting<T>={method<U>(): new<W>()=>T&U&W};
On 4a85546 this errors on T (as above), U is correct, and claims W is on an anonymous function rather than a ctor (missing the new keyword). (Which is possibly a formatting bug for that kind of ctor type signature, but could be indicative of something else)
Activity
weswigham commentedon Sep 5, 2015
This happens with the following SyntaxKinds in the definition:
Since all of those are 'isFunctionLike`, and are returned by getContainingFunction but are not the node on which that type parameter lies. (I believe)
Here's a comprehensive set of tests exposing the issues:
The issue is on ~line 4228 of
services.ts. We callgetContainingFunction(location)when what we really want is something else. What we want to know if the type parameter is derived from its enclosing function or its enclosing type alias, and the presence of a containing function-like node is not enough information to determine that.weswigham commentedon Sep 5, 2015
I also advise checking against the quick infos for this, in additon to those in the test above:
On 4a85546 this errors on
T(as above),Uis correct, and claimsWis on an anonymous function rather than a ctor (missing thenewkeyword). (Which is possibly a formatting bug for that kind of ctor type signature, but could be indicative of something else)