programming.dev
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
SlimTim10 to TypeScript · 2 years ago

TypeScript's Hidden Feature: Subtypes

message-square
3
link
fedilink
6

TypeScript's Hidden Feature: Subtypes

SlimTim10 to TypeScript · 2 years ago
message-square
3
link
fedilink
alert-triangle
You must log in or # to comment.
  • towerful
    link
    fedilink
    arrow-up
    3
    ·
    2 years ago

    I presume the details of this post got lost somewhere?

    let x = () => ({ name: "Alice" });
    let y = () => ({ name: "Alice", location: "Seattle" });
    x = y; // OK
    y = x; // Error, because x() lacks a location property`
    

    https://www.typescriptlang.org/docs/handbook/type-compatibility.html

    There doesn’t seem to be an article directly on subtypes

    • Jimbabwe@lemmy.world
      link
      fedilink
      arrow-up
      4
      ·
      2 years ago

      Typescript error in Post. Was expecting argument of type Link, received undefined.

  • HumanBehaviorByBjork [any, undecided]@hexbear.net
    link
    fedilink
    English
    arrow-up
    1
    ·
    2 years ago

    bottom-speak

TypeScript

typescript

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: [email protected]
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 1 user / day
  • 1 user / week
  • 12 users / month
  • 79 users / 6 months
  • 376 local subscribers
  • 1.07K subscribers
  • 89 Posts
  • 92 Comments
  • Modlog
  • mods:
  • snowe
  • Thomas@lemmy.douwes.co.uk
  • Ategon
  • BE: 0.19.13
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org