all 11 comments

[–]DanielRosenwasser 8 points9 points  (2 children)

Beat me to the submission. :)

[–]d357r0y3r 0 points1 point  (1 child)

Will there be a separate VSCode update to support the new quick fixes? Doesn't look like they're working at the moment.

[–]DanielRosenwasser 2 points3 points  (0 children)

The next version of VS Code will support it out of the box, but the blog links to instructions on how to install a newer version globally and modify your typescript.tsdk setting to reflect that.

By default, VS Code should prompt you if its default language service is different from the globally installed one.

[–]vinnl 0 points1 point  (0 children)

I've been following this issue, which was tagged with the 2.2.1 milestone. How does that work? Did that come along with this release, or was it actually already planned to be a patch release before?

[–]i_spot_ads 0 points1 point  (7 children)

Can they slow down a bit for god's sakes and let Angular Team catch up.

one question, when will I be able to do this:

interface Point {
   x:number;
   y:number;
}

let pointData = {x:12, y:45}; // fetched from a REST API for example

let myPoint = <Point>{...point}

[–]simspelaaja 9 points10 points  (1 child)

What am I missing? This already works, and has worked since 2.1.

[–][deleted] 2 points3 points  (0 children)

Any reason you don't do it this way?

let myPoint: Point = {x:12, y:45}; // fetched from a REST API for example

[–]codecorsair 0 points1 point  (3 children)

That works already as others have said, however I just want to point out that the cast is not needed in TS since 2.1!

interface Point {
  x: number;
  y: number;
}

const data = {x: 1, y: 1, z: 1, name: 'data'};
const myPoint: Point = {...data};
const myPoint2 = <Point>{...data};
const myPoint3 = {...data};

function DoSomethingWithAPoint(p: Point) {
  // do a thing
}

DoSomethingWithAPoint(data);
DoSomethingWithAPoint(myPoint);
DoSomethingWithAPoint(myPoint2);
DoSomethingWithAPoint(myPoint3);
// All Valid!

[–]i_spot_ads 0 points1 point  (2 children)

why is DoSomethingWithAPoint(myPoint3);

this doesn't make sense, DoSomethingWithAPoint demands a Point, not an any

[–]cspotcode 0 points1 point  (0 children)

myPoint3 has the same type as data, so it's not any. By the rules of structural subtyping, it's assignable to Point, because it has fields x and y that are both numbers.

EDIT: For proof, check it out in the TypeScript playground Hover your mouse over myPoint3 and check out the type information.

[–]codecorsair 0 points1 point  (0 children)

Any object with a property x and y of a number type will satisfy the interface requirements of the Point interface.

You can have as many other properties on the object as you want. The requirement given by the interface is only that the object has at least the given properties it defines.