Junior — Middle
Milliseid TypeScript versioone pidite oma projektides kasutama?
sobes.tech AI
Vastus AI-lt
In TypeScript projects, versions starting from 2.x and above are often used because they add important improvements and new features.
For example:
- TypeScript 2.0 introduced strict null and undefined checks.
- Versions 3.x added support for optional chaining, improvements in types, and support for new ECMAScript features.
- In the latest versions (4.x), template literal types, improved type checking, and other extensions have been introduced.
The choice of version depends on the project requirements and the tools used. It is important to keep the version up-to-date to utilize modern features and improved typing.
Example of using optional chaining (available from TypeScript 3.7):
interface User {
address?: {
street?: string;
};
}
const user: User = {};
console.log(user.address?.street); // safe access without error