Using Typescript in Node.js

  Рет қаралды 139,428

Ben Awad

Ben Awad

Күн бұрын

How to setup and use Typescript in Node.js
----
If you like cooking, checkout my side project: www.mysaffrona...
----
Join the Discord: / discord
----
Patreon: / benawad
----
Follow Me Online Here:
Twitch: / benawad
GitHub: github.com/ben...
LinkedIn: / benawad
Instagram: / benawad97
Twitter: / benawad
#benawad
TikTok: / benawad ​

----
Follow me online: voidpet.com/be...
#benawad

Пікірлер: 112
@zokalyx
@zokalyx 3 жыл бұрын
I've never been so excited for getting more squiggly red lines
@otisbraxton4653
@otisbraxton4653 3 жыл бұрын
I know im asking the wrong place but does any of you know of a way to log back into an Instagram account?? I stupidly forgot my password. I appreciate any assistance you can offer me!
@tysondaniel2419
@tysondaniel2419 3 жыл бұрын
@Otis Braxton instablaster =)
@DuraanAli
@DuraanAli 4 жыл бұрын
4:26 "No demon is ganna watch our files" lol
@govind22703
@govind22703 3 жыл бұрын
😂😂
@uran1980video
@uran1980video 5 жыл бұрын
Hi, Ben. Greate video! Please, do more videos for practical usage of typescript in regular projects. Thanks a lot
@bawad
@bawad 5 жыл бұрын
Sure
@craigjohnson8279
@craigjohnson8279 5 жыл бұрын
Great video Ben! I'm glad that you did this from scratch. That way we can code along.
@maxiequa567
@maxiequa567 5 жыл бұрын
Awesome introduction to the subject Ben, your enthusiasm for TS is also highly motivating, thanks.
@srinivasvalekar9904
@srinivasvalekar9904 4 жыл бұрын
9:36 saved days of restarting visual code for me. Thanks Ben. Subscribed and bookmarked this video.
@bawad
@bawad 4 жыл бұрын
Welcome :) you might also like my vscode tips video: benawad.com/vscode
@neociber24
@neociber24 3 жыл бұрын
People that write entire projects in JS are absolute madman.
@illya_ike
@illya_ike 3 жыл бұрын
it is good to know that you can escape type limitations with type any, but it is better not to show this trick to juniors )) as they will use any way too much, turning typescript code into JavaScript defeating the purpose.
@BuildWithAITools
@BuildWithAITools 5 жыл бұрын
The best intro to typescript.
@bawad
@bawad 5 жыл бұрын
thanks!
@adriannlara
@adriannlara 5 жыл бұрын
with Vim extension you can G + D to go to definition
@mahendraverma3459
@mahendraverma3459 2 жыл бұрын
Hi Ben, This is a great tutorial for starting to work on node. I will appreciate if you could make a video to use the same code (library) in browser and as well as in server.
@hamzehhanandeh3647
@hamzehhanandeh3647 3 жыл бұрын
Thank you
@Voldeblort
@Voldeblort 2 жыл бұрын
13:12 "... when you know your code is right." So never 🤣🤣
@juancamiloq1
@juancamiloq1 5 жыл бұрын
Awesome video as always Ben.
@zephieethan7168
@zephieethan7168 Жыл бұрын
just explained what i was wondering about. thanks, Ben.
@akovn107
@akovn107 2 жыл бұрын
Hi Ben. thanks for your great tutorial, I wonder how do you get those auto suggestions on terminal? what should I use to get that? I'm on Linux by the way.
@simopr09
@simopr09 4 жыл бұрын
Thanks Ben! great tutorial. Definitely subscribing! keep up the good work
@nikoszervo
@nikoszervo 3 жыл бұрын
watch this at 2x speed. In 10 minutes I learned quite a lot of stuff!!!
@RafiqueMohammed
@RafiqueMohammed 3 жыл бұрын
Subscribed rightaway! Please upload more video and also cover nodejs without using express! Awesome tutorial !!
@deveshmeena2573
@deveshmeena2573 Жыл бұрын
Amazing video! Really helped me understand typescript a lot better.
@akashshrestha01
@akashshrestha01 3 жыл бұрын
great more videos on ts + node plz
@zlatkoiliev8927
@zlatkoiliev8927 2 жыл бұрын
Hey Ben, really good stuff! I wasted so much time wondering how can I attach new prop to the req object and still make typescript happy. I have one issue with casting it to any, when I am trying to catch the user in a middleware I will have to cats req to any on that place too. Is there any way I can maybe extend the namespace or extend the type and use it globally instead?!? I wish I have the type definitions for req and just add the props I need.
@krasen4oo
@krasen4oo 5 жыл бұрын
So much time spent on casting as any, ts-ignore, and avoiding the type errors. Learning to use types correctly is much more valuable.
@barnabaskalydy6260
@barnabaskalydy6260 2 жыл бұрын
Great video, thank you!
@tech3425
@tech3425 Жыл бұрын
Cool stuff!
@zik9326
@zik9326 3 жыл бұрын
Great, it help me a lot. Thanks Ben!
@keivansf3459
@keivansf3459 2 жыл бұрын
Thanks for this
@talhakhan3010
@talhakhan3010 2 жыл бұрын
hey ben, this is a very concise video.. thank u very much... :)
@Yo-yx8wo
@Yo-yx8wo 3 жыл бұрын
wow, amazing video, all the we need in just one place, thank you so much
@MaxPicAxe
@MaxPicAxe 5 жыл бұрын
I agree with using interface for objects
@gabrielaugusto6001
@gabrielaugusto6001 2 жыл бұрын
oh dude, thank u so much for this video!
@bronze_painter
@bronze_painter 4 жыл бұрын
Super informative. Thank you for doing this! Subscribed!
@inanbunyamin
@inanbunyamin 3 жыл бұрын
Thank you for the video. Would you please tell me which bash you are using in your vscode terminal?
@bhavinpatil8020
@bhavinpatil8020 3 жыл бұрын
Brilliant it helped me in my work thanks!
@RoyerAdames
@RoyerAdames 3 жыл бұрын
You make great videos
@itsdavidmora
@itsdavidmora 4 жыл бұрын
So helpful!
@elEntrampe
@elEntrampe 4 жыл бұрын
Its like magic ! thanks for the videos!
@taylorcantwell7973
@taylorcantwell7973 3 жыл бұрын
excellent scontent chap
@thangphan6047
@thangphan6047 2 жыл бұрын
Thank you so much.
@TheLondekZdroj
@TheLondekZdroj 5 жыл бұрын
Very amusing video, looks like you're reading somebody else's examples not quite understanding what's what. :D
@ethancollins5807
@ethancollins5807 4 жыл бұрын
Why watch a tutorial if you feel like you’re above it? Not gonna get far in the tech community if you belittle others.
@shijinnath9065
@shijinnath9065 4 жыл бұрын
Awesome video. Thank you for doing the video
@undonejs
@undonejs 4 жыл бұрын
Thanks Ben! Your video is really cool, and you type code so fast! It seems that you used vscode + vim, right?Could you please tell me how to config that? or what things should I learn?
@bawad
@bawad 4 жыл бұрын
yeah: benawad.com/vim benawad.com/vscode
@SpooningTreesap86
@SpooningTreesap86 2 жыл бұрын
How do you get color coded intellisense hints like at 6:00 such as the function keyword being blue, params a lighter blue with types as green etc? My intellisense hints are just white or grey
@vaibhavm1986
@vaibhavm1986 4 жыл бұрын
Very informative
@haiderimam8977
@haiderimam8977 3 жыл бұрын
5:52 how did the dropdown appear?? also can we somehow see the dropdown even if we aren't destructuring?
@oussamasethoum2755
@oussamasethoum2755 4 жыл бұрын
Thank You ❤
@italogothardo
@italogothardo Жыл бұрын
thx for share this content! =D
@rocktonicy7688
@rocktonicy7688 3 жыл бұрын
very useful Thanks
@dhidhi1000
@dhidhi1000 Жыл бұрын
"An async function or method in ES5/ES3 requires the 'Promise' constructor" Cannot create a simple demo without running into errors in the first 10 seconds, typescript is very nice
@flodemonnn
@flodemonnn 4 жыл бұрын
How are you getting color in the "Read more" pop-up from Intellisense ? 6:38 ?
@bawad
@bawad 4 жыл бұрын
I'm not sure, I don't remember turning on a setting for it just always been like that
@arkadiuszcholewa5617
@arkadiuszcholewa5617 5 жыл бұрын
Hi! How you set up fish terminal in VS Code?
@bawad
@bawad 5 жыл бұрын
gist.github.com/benawad/1e9dd01994f78489306fbfd6f7b01cd3#file-settings-json-L50
@arkadiuszcholewa5617
@arkadiuszcholewa5617 5 жыл бұрын
@@bawad Thank you! :)
@obinna_okechukwu
@obinna_okechukwu 5 жыл бұрын
Thanks for the video. What's your suggestion of a workflow for development and deployment of a TypeScript node application. Say for instance a GraphQL server written in TypeScript. Do I build, then upload the build to the server or upload the ts files to the server and then build there is some other elegant continous integration workflow. Thanks in advance.
@bawad
@bawad 5 жыл бұрын
depends what your using to host your project sounds like you may be using a vps. For that you can just build your code locally and upload it to the vps
@obinna_okechukwu
@obinna_okechukwu 5 жыл бұрын
@@bawad yea, I use a vps. Thanks for your suggestion. Appreciate!
@zindev
@zindev 4 жыл бұрын
Hey Ben, as you type here at 10:09 the intellisense automatically show up telling you the types. How you'd set that?
@bawad
@bawad 4 жыл бұрын
benawad.com/vscode
@АлександрКот-ъ9х
@АлександрКот-ъ9х 4 жыл бұрын
How to debug ts?
@Steve-Richter
@Steve-Richter 4 жыл бұрын
How does downstream code in express know that middleware has added properties to the request object?
@bawad
@bawad 4 жыл бұрын
I usually do an if statement
@Luxcium
@Luxcium 5 жыл бұрын
Can you review my TypeScript VsCode theme of colour and syntax coloring ?? Pop N’ Loc Theme by Luxcium in the extention store
@bawad
@bawad 5 жыл бұрын
looks pretty good
@Luxcium
@Luxcium 5 жыл бұрын
Ben Awad too many hours in the development of that theme I cannot believe les than 6 months later 5000 person using it !!!
@kid_kulafu_1727
@kid_kulafu_1727 4 жыл бұрын
youre my hero!
@stxnw
@stxnw 2 жыл бұрын
as of now, ts-node-dev doesn't work on the latest version of TS
@husreihn1070
@husreihn1070 5 жыл бұрын
What do you use for cli, your cli hints you what you are going to type next... Can i use this in windows as well? whats the name of that cli? or plugin
@bawad
@bawad 5 жыл бұрын
fishshell.com/
5 жыл бұрын
I noticed that people are very often confused about interface vs type so i recently published a whole article just about this: pawelgrzybek.com/typescript-interface-vs-type/ Great vide o Ben as always. Keep on doing an amazing work!
@kps2642
@kps2642 5 жыл бұрын
woah awesome read, thanks
@piyushaggarwal5207
@piyushaggarwal5207 2 жыл бұрын
No Demon 😆
@pranjalagnihotri6072
@pranjalagnihotri6072 3 жыл бұрын
ts-node does not work with path aliases
@RehanKhan-xf3ml
@RehanKhan-xf3ml 2 жыл бұрын
What do you use for terminal auto complete
@ericsmith9293
@ericsmith9293 2 жыл бұрын
Z shell + autosuggestions plugin or fish
@JurajPecháč
@JurajPecháč 5 жыл бұрын
Difference between tsc --init and npx tsc --init?
@devianllert8192
@devianllert8192 5 жыл бұрын
Npx installs a dependency, executes and then deletes
@Max-xp3tf
@Max-xp3tf 3 жыл бұрын
Noice
@treezc8136
@treezc8136 3 жыл бұрын
Thanks alogototltltlgglgltltototototoyotoyototottototototoooooo love you ben :)
@Steve-Richter
@Steve-Richter 4 жыл бұрын
Why use yarn instead of npm? Any advantages?
@bawad
@bawad 4 жыл бұрын
seems to be faster for me
@milon27
@milon27 2 жыл бұрын
how to deploy it
@donkey7921
@donkey7921 Жыл бұрын
says this is for beginners, proceeds to use 'yarn'...
@soulninjadev
@soulninjadev 2 жыл бұрын
how does he not have a node_modules folder
@jacoblee6230
@jacoblee6230 5 жыл бұрын
4:17 Anyone know how he removed code inside double quote ?
@bawad
@bawad 5 жыл бұрын
vim hotkey: ct" kzbin.info/www/bejne/f5raeJWZmZ2Gbas
@rohanbansal3099
@rohanbansal3099 4 жыл бұрын
An alternative that lets you place your cursor anywhere in the double quotations (and not just the first character) is `di"`. Also works for brackets, curly braces, parentheses etc.
@rizaanjappie
@rizaanjappie 4 жыл бұрын
Or you could use asp.net core webapi
@everyhandletaken
@everyhandletaken 3 жыл бұрын
Or you could not
@RafaelMendes-yw2jm
@RafaelMendes-yw2jm Жыл бұрын
Why you never import any file, is that the way you program things? sounds very spaghetti!
@bhaveshkumar9995
@bhaveshkumar9995 5 жыл бұрын
Hi Ben, with this tsconfig : github.com/benawad/node-ts-graphql-boilerplate/blob/master/tsconfig.json It is working fine with ts-node-dev --respawn src/index.ts command When I do build using tsc -w -p ./tsconfig.json and run node file under dist folder it is giving me error (function (exports, require, module, __filename, __dirname) { import { Field, ID, ObjectType } from "type-graphql"; ^ SyntaxError: Unexpected token { Any idea?
@yuriihusak1959
@yuriihusak1959 4 жыл бұрын
13:15 you are not right! you are mutating req object, that is why you have this behaviour. req and res are object which provide you their API to use , do not user them as some kind of containers for you random props. 14:58 - just set with default value (a: number, b: number = 0) and stop making this mess
@MAC0071234
@MAC0071234 3 жыл бұрын
Exactly!! Thank You. I see it so often, that the people who are so stuck up and vocal about "Typescript" are the ones who can't code properly even the simple stuff. And I am like, "oh now I understand, why they say that typescript helps them catch so many silly errors". And by the like to dislike ratio you can tell that there are probably 18 people as of now who know how to code. Typescript is great but if you don't know how to code, then you are going to make more errors than a person who knows how to code will ever make in javascript or any other language.
@chetan9533
@chetan9533 2 жыл бұрын
but middlewares often do need to attach a property to request object so info can be passed onto next call. what's the correct way to handle that?
@yuriihusak1959
@yuriihusak1959 2 жыл бұрын
@@chetan9533 that is the right observation and questions! 1) think of how to wrap middlewares with a function that provides an additional argument which can be used for storing the data 2) think of having a global (within the file) Map object where keys are req objects and values are the extra data. Of course in this case you have to think how to clean up data in the end, but that shouldn't be difficult
@yuriihusak1959
@yuriihusak1959 2 жыл бұрын
@@chetan9533 there are more approaches you can think of
@yeicore
@yeicore 4 жыл бұрын
Node but it's Deno
@theacid1
@theacid1 3 жыл бұрын
What the heck is yarn
@everyhandletaken
@everyhandletaken 3 жыл бұрын
If you use npm, don’t worry about it :)
@mma.madallangusstawmmasill2403
@mma.madallangusstawmmasill2403 4 жыл бұрын
Gusttaw mmä
@andrewsabato6887
@andrewsabato6887 4 жыл бұрын
That code looks disgusting. You job now on is to fix typescript errors, yeah no thanks.
@everyhandletaken
@everyhandletaken 3 жыл бұрын
In English please?..
Typescript Generics Tutorial
21:56
Ben Awad
Рет қаралды 219 М.
Restful API with NodeJS, Express & Typescript [2020]
24:07
The Nerdy Canuck
Рет қаралды 46 М.
Minecraft Creeper Family is back! #minecraft #funny #memes
00:26
АЗАРТНИК 4 |СЕЗОН 3 Серия
30:50
Inter Production
Рет қаралды 931 М.
GIANT Gummy Worm Pt.6 #shorts
00:46
Mr DegrEE
Рет қаралды 14 МЛН
How To Use TypeScript With Express & Node
17:05
Colt Steele
Рет қаралды 71 М.
A subscriber was asked these interview questions for a junior role
44:35
Полная настройка Node.js с TypeScript в 2023
17:36
Владилен Минин
Рет қаралды 35 М.
Typescript tsconfig tutorial
15:52
Ben Awad
Рет қаралды 24 М.
JWT Authentication Node.js Tutorial with GraphQL and React
3:04:08
TypeScript Origins: The Documentary
1:21:36
OfferZen Origins
Рет қаралды 287 М.
Node.js is a serious thing now… (2023)
8:18
Code With Ryan
Рет қаралды 647 М.
React Typescript Tutorial
23:33
Ben Awad
Рет қаралды 575 М.
I loved solving this junior react interview challenge
26:02
Web Dev Cody
Рет қаралды 154 М.
Minecraft Creeper Family is back! #minecraft #funny #memes
00:26