TypeScript Tutorial #10 - Function Signatures

preview_player
Показать описание
Hey gang, in this TypeScript tutorial we'll take a look at how we can defined function signatures.

🐱‍👤🐱‍👤 JOIN THE GANG -
----------------------------------------
🐱‍💻 🐱‍💻 My Udemy Courses:

🐱‍💻 🐱‍💻 Course Files:

🐱‍💻 🐱‍💻 Other Related Free Courses:

🐱‍💻 🐱‍💻 TypeScript Docs:

🐱‍💻 🐱‍💻 The Net Ninja Community Boards:
Рекомендации по теме
Комментарии
Автор

I think that defining the function signature is best achieved by using a type alias. I'd rewrite it in this way:

type Calc = (a: number, b: number, c: string) => number

let calcFunction: Calc = (a, b, c) =>{
console.log(c)
return a+b
}

GuitarreroDaniel
Автор

I am so excited I am finally learning TypeScript with this wonderful series. Thanks Shaun.

Shakeel
Автор

These tutorials are amazing, I've been half-knowing typescript for a while but concisely explain these concepts in a simple manner and it's amazing to finally understand it.

Good series! 👏🛹

tonksonk
Автор

Thanks for the tuts, Shaun!

Quick question - Do we always have to specify the types for the argument variables during the function definition even after it's already done in the function signature?

boggyice
Автор

hey there late to the party here but thanks so much for the vids on this and everything else you do. Question in functions signatures why do you declare the types twice? if we initialize a function with specific types for params and return type why assign them again when defining the method?

heliosh.kamarasov
Автор

A function signature is basically like a method signature in an interface or an abstract method/function in striclty typed langs like java/c#

alakerejenus
Автор

hi shaun, I have a doubt. If we have already set what type the parameters should be in the signature, why do we need to define them in the function definition? could you please explain?

SparrowVivek
Автор

Forgive me if I'm about to out myself as an amateur, but I'm struggling to figure out how predefining a function is useful. Can anyone give me any examples where you might want to do this?

CherryHavoc
Автор

This is great. Do you think you'd do a TypeScript with React series?

thetech
Автор

Why do so many people recommend to let TS infer types? The purpose of TS is to to allow types in the JavaScript language. So why not make use of that to create clean readable code? I program in languages where there is no type inference, and you must provide types. So to hear people suggesting to allow TS to infer seems like craziness. Maybe I'm old 🤣 Non the less, excellent videos thank you.

JayJay-kimi
Автор

This function signatures reminds me of the use of interface, does it?

arcygutierrez
Автор

In signature below name of "obj" doesnt matter, but it does for "name" and "age"
let logInfo:(obj:{name:string, age:number})=> void

Question:
How can we write signature that says logInfo is a function that takes 1 object parameter, and this object has to have 1 value of string type and second value of number, but names of the keys could be anything?

szymonjankowski
Автор

Hi! Which theme are you using? thanks!

Sesg-JN
Автор

Hello Shaun, Why do we need to define the signature?

johnmoore
Автор

cant we define function right away instead of create variable for function first and then the function? im still new and bit confused about that.

lukalastname
Автор

export function name<type>()=>void{....}
is equal?
export const name:type = ()=>void{...}

EduardoMazolini
Автор

Adding types to parameters is unnecessary if the function signature has been defined.

Nexus-rtbm
Автор

why do we write prop types again when we using functions ?

sevgisartas
Автор

This is great.. so well explained <3 ...
btw how to I get this syntax color scheme??

tanishagarwal
Автор

Why doesn't this return an error?
let calc: (a: number, b: number, c: string) => void;
calc = (numOne: number, numTwo: number, action: string) => {
if (action === "add") {
return numOne + numTwo;
}
};

questreal
join shbcf.ru