Latest video
Latest posts

Fix type X is not assignable to type Y

Best Practices

The error message that undefined cannot be assigned to a specific type often occurs when working with optional parameters. When a parameter is marked as optional, it can either be undefined or of the specified type. In TypeScript this is represented by a union type such as undefined | string. If you want to use a function that doesn’t accept undefined as a parameter (e.g., parseInt), you must first validate that your value exists.

Here are some helpful tricks for accomplishing this.

Continue reading →

Error TS2307: Cannot find module events


Extending the EventEmitter class from Node.js might cause error TS2307. Here is how to fix it.

Continue reading →