The main difference between unknown and any is that unknown is much less permissive than any: we have to do some form of checking before performing most operations on values of type unknown, whereas we don't have to do any checks before performing operations on values of type any.
All Posts tagged as "TypeScript"
You'll need those tips one day if you get used to RxJS 🤣
I'll show you how to migrate from TSLint to ESLint and using husky to run lint every time you try to make a commit
A simple walk through how to use the browser MediaDevices for capturing picture from a webcam in Angular
Do you know you can use Observable for Angular Output?
The holiday session is coming. Let add a simple snow effect to your Angular application ❄️❄️❄️
We will write a custom directive to disable a reactive form control by passing a boolean flag on the template
My eight tutorial is to explain how to build a placeholder loading component
My seventh tutorial will focus on another kind of text editor - a rich text HTML editor
Use let k: keyof T and a for-in loop to iterate objects when you know exactly what the keys will be or Object.entries to iterate over the keys and values of any object.
Prefer async/await to raw Promise when possible. They produce more concise, straightforward code and eliminate whole classes of errors.
Should you use type or interface? For complex types, you have no choice: you need to use a type alias. But what about the simpler object types that can be represented either way? To answer this question, you should consider consistency and augmentation. Are you working in a codebase that consistently uses interface? Then stick with interface. Does it use type? Then use type.
My sixth tutorial will focus on another interesting feature - a markdown text editor
Consider applying type annotations to entire function expressions, rather than to their parameters and return type. If you're writing the same type signature repeatedly, factor out a function type.
My fifth tutorial will focus on one of the most interesting feature - drag and drop board
My fourth tutorial will focus on the first custom UI element - editable textbox
My third tutorial will go further into the application state management with Akita
My second tutorial will walk you through how to build the application layout that has navigation, sidebar and content section
There were quite a lot of changes between Phaser 2 and 3 but I like version 3 better. It made the code much more readable and structure
I made a retro Tetris game with Angular. The first game that I have ever built :)
I spent my spare time to build a cloned Jira app with Angular 9, Akita and ng-zorro in about two weeks, including the weekend
You should know some basic Angular, TypeScript and git knowledge before starting
I spent my spare time to build a cloned Jira app with Angular 9, Akita and ng-zorro in about two weeks time, including the weekend.
Repost my killer answer on StackOverflow with more than 600 votes
If you have multiple concrete classes that inherit from the same base class, or implement the same interface. You should consider using visitor pattern. It will save you from dozens of if-else block or switch/case and typecasting
You could use an extension for VSCode for converting C# class to TypeScript class in a few seconds 🥰
I like the Redux concept. But not NgRx :)
null and undefined are the root of all evil. It often leads to runtime errors. It is easy to write code that will throw Error at runtime.
To define the function callback type. You could declare an interface that has a call signature. Or define a new type
Not all the time we need to cast from JSON object to a class, but sometimes it is really helpful. Use class-transformer to transform JSON object to class instance
Another interesting tree traverse problem that could land you a job 🤓
Vertically center in CSS has never been an easy problem
I found that source-map-explorer tool shows an easy-to-understand-and-explore visualization to help you debug where all the code is coming from.