DEV Community

Cover image for type variables in typescript
cem kaan kosali
cem kaan kosali

Posted on • Edited on

1

type variables in typescript

  1. I watched 20 minutes of Data structures. I finished Priority Queue.
  2. I've tried some different layouts in nativescript-vue in play.nativescript.org.
  3. I wrote a little bit more on functional typescript.

May be I will use StackLayout instead of GridLayout

        <StackLayout orientation="horizontal" backgroundColor="lightgray">
            <Label v-for="n in item.totalLabelsCount" :text="item.id"
                width="30" height="150" backgroundColor="white"
                class="border" />
        </StackLayout>
Enter fullscreen mode Exit fullscreen mode

I am trying to come with an idea about how to explain type variables in Typescript

Did you know there are type variables in typescript? You don't need to know type of a result from a function. You can just use a variable for whatever this type will be. Cool right?

function identity<T>(arg: T): T {
    return arg;
}
Enter fullscreen mode Exit fullscreen mode

Please check out:
https://www.typescriptlang.org/docs/handbook/functions.html#rest-parameters

https://www.typescriptlang.org/docs/handbook/generics.html#working-with-generic-type-variables

day22

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →