
I'm a software engineer interested in Cloud technologies and web applications.
Search for a command to run...

I'm a software engineer interested in Cloud technologies and web applications.
TypeScript is great. I don't want to start any project without TS, especially not in teams.
Good introduction, Phillip. Hopefully, this convinces some people using TS.
Thank you Jannik Wempe!
A lot of the documentation can be found here on Spring's website about the threat. The most important part is the second paragraph. Spring Boot users are only affected by this vulnerability if they have switched the default logging system to Log4J2....

AWS CDK Pro Tips

Query a Postgres database using a Lambda in 5 minutes!

Learn about the benefits of serverless

TypeScript is a strict superset of ECMAScript 2015, which is itself a superset of ECMAScript 5, commonly referred to as JavaScript. As such, a JavaScript program is also a valid TypeScript program, and a TypeScript program can seamlessly consume JavaScript. - Wikipedia
One of the best features of TypeScript is, wait for it, Types! However, one of the most cumbersome features of TypeScript, for newbies, is Types! Let's talk about what they are, why you should use them, and the problems they can cause.
TypeScript is a strongly typed, object-oriented, compiled language. Conversely, JavaScript is not strongly typed. In JavaScript, a variable can take many forms. A variable can be any type of object. For example a String or a Number. However, in TypeScript an object can only be one or the other.
// this is valid in JavaScript
let name = "Phillip";
name = 4;
// this is NOT valid in TypeScript
let name: String = "Phillip";
name = 4; // this will cause compiler errors!
Types are great! They allow you to see which fields are available for an object. It also prevents developers from assigning the wrong value to a field.
A wonderful example is refactoring. I recently had to make major updates to an Angular application. Since we use Types we were able to easily modify fields and the compiler allowed us to easily make the appropriate changes to fix them! ALL HAIL TYPESCRIPT! ππ½
A Type in TypeScript is a simple interface. You define fields and the distinct type of the field.
interface User {
id: number;
name: string;
dateOfBirth: date;
age: number;
funFacts: string[];
activeFlg: boolean;
mother: User;
father: User;
someObj: any;
idk: unknown;
}
A strongly typed language means there is less flexibility. You need to define what your interfaces will look like. Based on how you configure your compiler there may be some strict rules to follow.
I have helped many developers debugs errors having to do with implicitly any. This means that a type for a parameter has not been explicitly defined.
Here are some examples of errors I have seen:
parameter 'req' implicitly has an 'any' type
parameter 'res' implicitly has an 'any' type
parameter 'res' implicitly has an 'any' type.ts(7006)
error ts7006: parameter 'req' implicitly has an 'any' type
error ts7006: parameter 'res' implicitly has an 'any' type
parameter 'user' implicitly has an 'any' type.ts(7006)
This is a great example of code that I found on StackOverflow which would produce one of these beautiful exceptions.
const users = [...]
// this line does not compile
let user = users.find(user => user.id === query);
The parameter user is being used in the find method but its type is unknown. Therefore, id may not be a valid attribute.
How do you fix this? π
You can EXPLICITLY use any! The any type allows us to assign literally βanyβ particular value to that variable, simulating vanilla JavaScript.
const users = [...]
let user = users.find((user: any) => user.id === query);
The best thing to do would be to use a type to define the users array or the find method.
interface User {id: number;...}
...
...
const users: User[] =[...]
let user = users.find(user => user.id === query);
In your tsconfig.json, add "noImplicitAny": false to "compilerOptions":{}.
What is
tsconfig.json? You will see this file is all TypeScript projects! This specifies the root files and the compiler options required to compile the project.{ "compilerOptions": { ... "noImplicitAny": false, ... }, "files": [ "core.ts", ... ] }
TypeScript is awesome! Almost all of the projects I work on today leverage TypeScript. I feel the pros far outweigh the cons of using TypeScript over vanilla JavaScript. I highly recommend giving it a try on your next project!
Pro Tip: If you know JavaScript you already know TypeScript! π
If you are interested in getting started with TypeScript read my article on How to Convert Express.js to Typescript!