TypeScript 2.2 tagged union auto-completion broken

 

I just installed TypeScript 2.2 and found that previously working auto-completion within type-narrowing of tagged union types no longer works.

For example:

interface Circle {
kind: "circle";
radius: number;
}

interface Rectangle {
kind: "rectangle";
width: number;
height: number;
}

declare const shape: Circle | Rectangle;
switch (shape.kind) {
case "circle":
shape.radius; // ".radius" auto-completes with 2.1, but not 2.2
break;
case "rectangle":
shape.width; // ".width" auto-completes with 2.1, but not 2.2
shape.height; // ".height" auto-completes with 2.1, but not 2.2
break;
}

4 comments
Comment actions Permalink

Is TypeScript service used for completion? In Preferences | Languages & Frameworks | TypeScript, press 'Configure' next to TypeScript service - is 'Code Completion' enabled?

Just checked 2017.1 EAP with bundled TypeScript 2.2.1 - completion works as expected:

0
Comment actions Permalink

Yes. The only difference is that I'm using IntelliJ IDEA 2016.3.4 and a custom compiler (since the bundled compiler is 2.0).

0
Comment actions Permalink

I just downloaded EAP 2017.1 and tried it out, and indeed the problem doesn't exist anymore. When is this expected to be released?

One small issue: the tooltip gives the union type when it should be narrowed:

Compared to the TS Playground:



 

0
Comment actions Permalink

2017.1 can be expected by the end of March

 

Tooltip shows the function declaration - just in the way it's declared in code

0

Please sign in to leave a comment.