> For the complete documentation index, see [llms.txt](https://university-west.gitbook.io/programming-paradigms/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://university-west.gitbook.io/programming-paradigms/web-development/scripting-languages/typescript.md).

# TypeScript

#### What is TypeScript?

TypeScript is a superset of JavaScript developed by Microsoft that adds static types to the language. It is designed for the development of large applications and transcompiles to JavaScript.

#### TypeScript vs. JavaScript

* **Static Typing**: TypeScript introduces static typing, allowing developers to define types for variables, function parameters, and return values. JavaScript is dynamically typed.
* **Class Features**: TypeScript supports modern JavaScript features as well as additional features such as enums and interfaces, providing more tools to catch errors at compile time.
* **Tool Support**: TypeScript offers enhanced autocompletion, navigation, and refactoring services in editors, thanks to its type information.
* **Compatibility**: TypeScript code is compiled down to JavaScript, making it compatible with any JavaScript environment.
* **Learning Curve**: JavaScript developers may face a learning curve with TypeScript's typing system and additional features, but the core language remains familiar.

#### Current Uses of TypeScript

* **Web Development**: Widely used in front-end and back-end development for structuring large and complex web applications.
* **Frameworks and Libraries**: Many popular frameworks and libraries like Angular, React (with TypeScript definitions), and Vue.js support or encourage using TypeScript for development.
* **Enterprise-Level Applications**: Its static typing and object-oriented features make TypeScript an ideal choice for enterprise-level applications that require maintainability and scalability.

```typescript
// Example of integrating TypeScript with a webpage

// Define an interface for a user
interface User {
  name: string;
  age: number;
}

// A function that takes a User object and returns a greeting message
function greetUser(user: User): string {
  return `Hello, ${user.name}! You are ${user.age} years old.`;
}

// Creating a User object
const user: User = {
  name: "John Doe",
  age: 30
};

// Using the function and displaying the greeting in the webpage
document.body.innerHTML = greetUser(user);
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://university-west.gitbook.io/programming-paradigms/web-development/scripting-languages/typescript.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
