Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError in getQuickInfoAtPosition for an intersection type #7966

Closed
mhegazy opened this issue Apr 8, 2016 · 0 comments
Closed

TypeError in getQuickInfoAtPosition for an intersection type #7966

mhegazy opened this issue Apr 8, 2016 · 0 comments
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@mhegazy
Copy link
Contributor

mhegazy commented Apr 8, 2016

Reported in #7934 (comment) by @Arnavion .

class A {
    static STATIC_A: string = 'A';
    instanceA: string = 'A';
    constructor() { }
}
class B {
    static STATIC_B: string = 'B';
    instanceB: string = 'B';
}


// Define a contract to bind an instance type param (T/Z) to its static "parent" (TType/ZType)
interface ConcreteTypeOf<T> extends Function { new (...args): T; }

// Explicitly say what we are dealing with:
class MergeTypes<T, TType extends ConcreteTypeOf<T>, Z, ZType extends ConcreteTypeOf<Z>> {
    constructor(private type1: TType, private type2: ZType) { }

    // We return a constructor for T & Z and intersect static members.
    merge(): ConcreteTypeOf<T & Z> & TType & ZType {
        // Do some work to mixin the types.
        return <any>{};
    }
}

let AB = new MergeTypes<A, typeof A, B, typeof B>(A, B).merge();    // Inferred AB: ConcreteTypeOf<A & B> & typeof A & typeof B
let ab = new AB();                                                  // Inferred ab: A & B

hover over AB in new AB().


TypeError: Unable to get property 'flags' of undefined or null reference
   at buildSymbolDisplay (:16512:17)
   at Anonymous function (:45473:13)
   at mapToDisplayParts (:45459:9)
   at symbolToDisplayParts (:45472:9)
   at getSymbolDisplayPartsDocumentationAndSymbolKind (:51614:41)
   at getQuickInfoAtPosition (:51917:13)
   at Anonymous function (:55942:119)
   at simpleForwardCall (:55793:9)
   at forwardJSONCall (:55809:13)
   at forwardJSONCall (:55855:13)
   at getQuickInfoAtPosition (:55942:13)

@mhegazy mhegazy added the Bug A bug in TypeScript label Apr 8, 2016
@DanielRosenwasser DanielRosenwasser changed the title TypeError in getQuicInfoAtPosition for an intersection type TypeError in getQuickInfoAtPosition for an intersection type Apr 10, 2016
@mhegazy mhegazy added this to the TypeScript 2.0 milestone May 10, 2016
@mhegazy mhegazy assigned ghost May 10, 2016
jeffrey-easyesi added a commit to Everlaw/nbts that referenced this issue May 12, 2016
ghost pushed a commit that referenced this issue May 12, 2016
…example, an intersection type.

(We still need the check for the Anonymous flags or else anonymous function tooltips will look like `var lambdaFoo: (Anonymous function)(a: number, b: number) => number'` instead of `var lambdaFoo: (a: number, b: number) => number`)
@ghost ghost closed this as completed in #8576 May 12, 2016
ghost pushed a commit that referenced this issue May 12, 2016
Fix #7966: A non-anonymous type can still fail to have a symbol.
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label May 12, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

1 participant