url stringlengths 24 106 | html stringlengths 41 53k | title stringlengths 0 63 |
|---|---|---|
https://www.typescriptlang.org/docs/handbook/declaration-files/library-structures.html | Library Structures
Broadly speaking, the way you structure your declaration file depends on how the library is consumed. There are many ways of offering a library for consumption in JavaScript, and you’ll need to write your declaration file to match it. This guide covers how to identify common library patterns, and ho... | TypeScript: Documentation - Library Structures |
https://www.typescriptlang.org/docs/handbook/declaration-files/by-example.html | Declaration Reference
The purpose of this guide is to teach you how to write a high-quality definition file. This guide is structured by showing documentation for some API, along with sample usage of that API, and explaining how to write the corresponding declaration.
These examples are ordered in approximately incre... | TypeScript: Documentation - Declaration Reference |
https://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-d-ts.html | Modules .d.ts
Comparing JavaScript to an example DTS
Common CommonJS Patterns
A module using CommonJS patterns uses module.exports to describe the exported values. For example, here is a module which exports a function and a numerical constant:
const maxInterval = 12;
function getArrayLength(arr) {
return arr.lengt... | TypeScript: Documentation - Modules .d.ts |
https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html | Introduction
The Declaration Files section is designed to teach you how to write a high-quality TypeScript Declaration File. We need to assume basic familiarity with the TypeScript language in order to get started.
If you haven’t already, you should read the TypeScript Handbook to familiarize yourself with basic conc... | TypeScript: Documentation - Introduction |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-1-3.html | TypeScript 1.3
Protected
The new protected modifier in classes works like it does in familiar languages like C++, C#, and Java. A protected member of a class is visible only inside subclasses of the class in which it is declared:
class Thing {
protected doSomething() {
/* ... */
}
}
class MyThing extends Thin... | TypeScript: Documentation - TypeScript 1.3 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-1-1.html | TypeScript 1.1
Performance Improvements
The 1.1 compiler is typically around 4x faster than any previous release. See this blog post for some impressive charts.
Better Module Visibility Rules
TypeScript now only strictly enforces the visibility of types in modules if the declaration flag is provided. This is very us... | TypeScript: Documentation - TypeScript 1.1 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-0.html | TypeScript 4.0
Variadic Tuple Types
Consider a function in JavaScript called concat that takes two array or tuple types and concatenates them together to make a new array.
function concat(arr1, arr2) {
return [...arr1, ...arr2];
}
Also consider tail, that takes an array or tuple, and returns all elements but the f... | TypeScript: Documentation - TypeScript 4.0 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-1-8.html | TypeScript 1.8
Type parameters as constraints
With TypeScript 1.8 it becomes possible for a type parameter constraint to reference type parameters from the same type parameter list. Previously this was an error. This capability is usually referred to as F-Bounded Polymorphism.
Example
function assign<T extends U, U>(... | TypeScript: Documentation - TypeScript 1.8 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-1-4.html | TypeScript 1.4
Union types
Overview
Union types are a powerful way to express a value that can be one of several types. For example, you might have an API for running a program that takes a commandline as either a string, a string[] or a function that returns a string. You can now write:
interface RunOptions {
prog... | TypeScript: Documentation - TypeScript 1.4 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-1-5.html | TypeScript 1.5
ES6 Modules
TypeScript 1.5 supports ECMAScript 6 (ES6) modules. ES6 modules are effectively TypeScript external modules with a new syntax: ES6 modules are separately loaded source files that possibly import other modules and provide a number of externally accessible exports. ES6 modules feature several ... | TypeScript: Documentation - TypeScript 1.5 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-1-7.html | TypeScript 1.7
async
/
await
support in ES6 targets (Node v4+)
TypeScript now supports asynchronous functions for engines that have native support for ES6 generators, e.g. Node v4 and above. Asynchronous functions are prefixed with the async keyword; await suspends the execution until an asynchronous function return ... | TypeScript: Documentation - TypeScript 1.7 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-1-6.html | TypeScript 1.6
JSX support
JSX is an embeddable XML-like syntax. It is meant to be transformed into valid JavaScript, but the semantics of that transformation are implementation-specific. JSX came to popularity with the React library but has since seen other applications. TypeScript 1.6 supports embedding, type checki... | TypeScript: Documentation - TypeScript 1.6 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-0.html | TypeScript 2.0
Null- and undefined-aware types
TypeScript has two special types, Null and Undefined, that have the values null and undefined respectively. Previously it was not possible to explicitly name these types, but null and undefined may now be used as type names regardless of type checking mode.
The type chec... | TypeScript: Documentation - TypeScript 2.0 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-1.html | TypeScript 2.1
keyof
and Lookup Types
In JavaScript it is fairly common to have APIs that expect property names as parameters, but so far it hasn’t been possible to express the type relationships that occur in those APIs.
Enter Index Type Query or keyof; An indexed type query keyof T yields the type of permitted pro... | TypeScript: Documentation - TypeScript 2.1 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html | TypeScript 2.2
Support for Mix-in classes
TypeScript 2.2 adds support for the ECMAScript 2015 mixin class pattern (see MDN Mixin description and “Real” Mixins with JavaScript Classes for more details) as well as rules for combining mixin construct signatures with regular construct signatures in intersection types.
Fi... | TypeScript: Documentation - TypeScript 2.2 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-3.html | TypeScript 2.3
Generators and Iteration for ES5/ES3
First some ES2016 terminology:
Iterators
ES2015 introduced Iterator, which is an object that exposes three methods, next, return, and throw, as per the following interface:
interface Iterator<T> {
next(value?: any): IteratorResult<T>;
return?(value?: any): Ite... | TypeScript: Documentation - TypeScript 2.3 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-4.html | TypeScript 2.4
Dynamic Import Expressions
Dynamic import expressions are a new feature and part of ECMAScript that allows users to asynchronously request a module at any arbitrary point in your program.
This means that you can conditionally and lazily import other modules and libraries. For example, here’s an async f... | TypeScript: Documentation - TypeScript 2.4 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-6.html | TypeScript 2.6
Strict function types
TypeScript 2.6 introduces a new strict checking flag, strictFunctionTypes. The strictFunctionTypes switch is part of the strict family of switches, meaning that it defaults to on in strict mode. You can opt-out by setting --strictFunctionTypes false on your command line or in your ... | TypeScript: Documentation - TypeScript 2.6 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html | TypeScript 2.7
Constant-named properties
TypeScript 2.7 adds support for declaring const-named properties on types including ECMAScript symbols.
Example
// Lib
export const SERIALIZE = Symbol("serialize-method-key");
export interface Serializable {
[SERIALIZE](obj: {}): string;
}
// consumer
import { SERIALIZE, Ser... | TypeScript: Documentation - TypeScript 2.7 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-5.html | TypeScript 2.5
Optional
catch
clause variables
Thanks to work done by @tinganho, TypeScript 2.5 implements a new ECMAScript feature that allows users to omit the variable in catch clauses. For example, when using JSON.parse you may need to wrap calls to the function with a try/catch, but you may not end up using the... | TypeScript: Documentation - TypeScript 2.5 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html | TypeScript 2.8
Conditional Types
TypeScript 2.8 introduces conditional types which add the ability to express non-uniform type mappings. A conditional type selects one of two possible types based on a condition expressed as a type relationship test:
T extends U ? X : Y
The type above means when T is assignable to U ... | TypeScript: Documentation - TypeScript 2.8 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-9.html | TypeScript 2.9
Support
number
and
symbol
named properties with
keyof
and mapped types
TypeScript 2.9 adds support for number and symbol named properties in index types and mapped types. Previously, the keyof operator and mapped types only supported string named properties.
Changes include:
An index type keyof ... | TypeScript: Documentation - TypeScript 2.9 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-0.html | TypeScript 3.0
Project References
TypeScript 3.0 introduces a new concept of project references. Project references allow TypeScript projects to depend on other TypeScript projects - specifically, allowing tsconfig.json files to reference other tsconfig.json files. Specifying these dependencies makes it easier to spli... | TypeScript: Documentation - TypeScript 3.0 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-1.html | TypeScript 3.1
Mapped types on tuples and arrays
In TypeScript 3.1, mapped object types[1] over tuples and arrays now produce new tuples/arrays, rather than creating a new type where members like push(), pop(), and length are converted. For example:
type MapToPromise<T> = { [K in keyof T]: Promise<T[K]> };
type Coord... | TypeScript: Documentation - TypeScript 3.1 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-3.html | TypeScript 3.3
Improved behavior for calling union types
In prior versions of TypeScript, unions of callable types could only be invoked if they had identical parameter lists.
type Fruit = "apple" | "orange";
type Color = "red" | "orange";
type FruitEater = (fruit: Fruit) => number; // eats and ranks the fruit
type C... | TypeScript: Documentation - TypeScript 3.3 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-2.html | TypeScript 3.2
strictBindCallApply
TypeScript 3.2 introduces a new strictBindCallApply compiler option (in the strict family of options) with which the bind, call, and apply methods on function objects are strongly typed and strictly checked.
function foo(a: number, b: string): string {
return a + b;
}
let a = foo.... | TypeScript: Documentation - TypeScript 3.2 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-9.html | TypeScript 3.9
Improvements in Inference and
Promise.all
Recent versions of TypeScript (around 3.7) have had updates to the declarations of functions like Promise.all and Promise.race. Unfortunately, that introduced a few regressions, especially when mixing in values with null or undefined.
interface Lion {
roar()... | TypeScript: Documentation - TypeScript 3.9 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html | TypeScript 3.7
Optional Chaining
Playground
Optional chaining is issue #16 on our issue tracker. For context, there have been over 23,000 issues on the TypeScript issue tracker since then.
At its core, optional chaining lets us write code where TypeScript can immediately stop running some expressions if we run into ... | TypeScript: Documentation - TypeScript 3.7 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html | TypeScript 3.4
Faster subsequent builds with the
--incremental
flag
TypeScript 3.4 introduces a new flag called incremental which tells TypeScript to save information about the project graph from the last compilation. The next time TypeScript is invoked with incremental, it will use that information to detect the le... | TypeScript: Documentation - TypeScript 3.4 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html | TypeScript 3.5
Speed improvements
TypeScript 3.5 introduces several optimizations around type-checking and incremental builds.
Type-checking speed-ups
TypeScript 3.5 contains certain optimizations over TypeScript 3.4 for type-checking more efficiently. These improvements are significantly more pronounced in editor s... | TypeScript: Documentation - TypeScript 3.5 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-6.html | TypeScript 3.6
Stricter Generators
TypeScript 3.6 introduces stricter checking for iterators and generator functions. In earlier versions, users of generators had no way to differentiate whether a value was yielded or returned from a generator.
function* foo() {
if (Math.random() < 0.5) yield 100;
return "Finishe... | TypeScript: Documentation - TypeScript 3.6 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html | TypeScript 3.8
Type-Only Imports and Export
This feature is something most users may never have to think about; however, if you’ve hit issues under isolatedModules, TypeScript’s transpileModule API, or Babel, this feature might be relevant.
TypeScript 3.8 adds a new syntax for type-only imports and exports.
import t... | TypeScript: Documentation - TypeScript 3.8 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-5.html | TypeScript 4.5
Supporting
lib
from
node_modules
To ensure that TypeScript and JavaScript support works well out of the box, TypeScript bundles a series of declaration files (.d.ts files). These declaration files represent the available APIs in the JavaScript language, and the standard browser DOM APIs. While there ... | TypeScript: Documentation - TypeScript 4.5 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-2.html | TypeScript 4.2
Smarter Type Alias Preservation
TypeScript has a way to declare new names for types called type aliases. If you’re writing a set of functions that all work on string | number | boolean, you can write a type alias to avoid repeating yourself over and over again.
type BasicPrimitive = number | string | b... | TypeScript: Documentation - TypeScript 4.2 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-1.html | TypeScript 4.1
Template Literal Types
String literal types in TypeScript allow us to model functions and APIs that expect a set of specific strings.
function setVerticalAlignment(location: "top" | "middle" | "bottom") {
// ...
}
setVerticalAlignment("middel");
Argument of type '"middel"' is not assignable to para... | TypeScript: Documentation - TypeScript 4.1 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-4.html | TypeScript 4.4
Control Flow Analysis of Aliased Conditions and Discriminants
In JavaScript, we often have to probe a value in different ways, and do something different once we know more about its type. TypeScript understands these checks and calls them type guards. Instead of having to convince TypeScript of a variab... | TypeScript: Documentation - TypeScript 4.4 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-7.html | TypeScript 4.7
ECMAScript Module Support in Node.js
For the last few years, Node.js has been working to support ECMAScript modules (ESM). This has been a very difficult feature, since the Node.js ecosystem is built on a different module system called CommonJS (CJS). Interoperating between the two brings large challeng... | TypeScript: Documentation - TypeScript 4.7 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-6.html | TypeScript 4.6
Allowing Code in Constructors Before
super()
In JavaScript classes it’s mandatory to call super() before referring to this. TypeScript enforces this as well, though it was a bit too strict in how it ensured this. In TypeScript, it was previously an error to contain any code at the beginning of a constr... | TypeScript: Documentation - TypeScript 4.6 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html | TypeScript 5.2
using
Declarations and Explicit Resource Management
TypeScript 5.2 adds support for the upcoming Explicit Resource Management feature in ECMAScript. Let’s explore some of the motivations and understand what the feature brings us.
It’s common to need to do some sort of “clean-up” after creating an obje... | TypeScript: Documentation - TypeScript 5.2 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html | TypeScript 5.0
Decorators
Decorators are an upcoming ECMAScript feature that allow us to customize classes and their members in a reusable way.
Let’s consider the following code:
class Person {
name: string;
constructor(name: string) {
this.name = name;
}
greet() {
console.log(`Hello,... | TypeScript: Documentation - TypeScript 5.0 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-1.html | TypeScript 5.1
Easier Implicit Returns for
undefined
-Returning Functions
In JavaScript, if a function finishes running without hitting a return, it returns the value undefined.
function foo() {
// no return
}
// x = undefined
let x = foo();
However, in previous versions of TypeScript, the only functions that c... | TypeScript: Documentation - TypeScript 5.1 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-8.html | TypeScript 4.8
Improved Intersection Reduction, Union Compatibility, and Narrowing
TypeScript 4.8 brings a series of correctness and consistency improvements under --strictNullChecks. These changes affect how intersection and union types work, and are leveraged in how TypeScript narrows types.
For example, unknown is... | TypeScript: Documentation - TypeScript 4.8 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-9.html | TypeScript 4.9
The
satisfies
Operator
TypeScript developers are often faced with a dilemma: we want to ensure that some expression matches some type, but also want to keep the most specific type of that expression for inference purposes.
For example:
// Each property can be a string or an RGB tuple.
const palette ... | TypeScript: Documentation - TypeScript 4.9 |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-3.html | TypeScript 5.3
Import Attributes
TypeScript 5.3 supports the latest updates to the import attributes proposal.
One use-case of import attributes is to provide information about the expected format of a module to the runtime.
// We only want this to be interpreted as JSON,
// not a runnable/malicious JavaScript file ... | TypeScript: Documentation - TypeScript 5.3 |
https://www.typescriptlang.org/docs/handbook/babel-with-typescript.html | Using Babel with TypeScript
Babel vs
tsc
for TypeScript
When making a modern JavaScript project, you might ask yourself what is the right way to convert files from TypeScript to JavaScript?
A lot of the time the answer is “it depends”, or “someone may have decided for you” depending on the project. If you are build... | TypeScript: Documentation - Using Babel with TypeScript |
https://www.typescriptlang.org/docs/handbook/migrating-from-javascript.html | Migrating from JavaScript
TypeScript doesn’t exist in a vacuum. It was built with the JavaScript ecosystem in mind, and a lot of JavaScript exists today. Converting a JavaScript codebase over to TypeScript is, while somewhat tedious, usually not challenging. In this tutorial, we’re going to look at how you might start... | TypeScript: Documentation - Migrating from JavaScript |
https://www.typescriptlang.org/docs/handbook/dom-manipulation.html | DOM Manipulation
DOM Manipulation
An exploration into the HTMLElement type
In the 20+ years since its standardization, JavaScript has come a very long way. While in 2020, JavaScript can be used on servers, in data science, and even on IoT devices, it is important to remember its most popular use case: web browsers.
W... | TypeScript: Documentation - DOM Manipulation |
https://www.typescriptlang.org/docs/handbook/gulp.html | Gulp
This quick start guide will teach you how to build TypeScript with gulp and then add Browserify, terser, or Watchify to the gulp pipeline. This guide also shows how to add Babel functionality using Babelify.
We assume that you’re already using Node.js with npm.
Minimal project
Let’s start out with a new direct... | TypeScript: Documentation - Gulp |
https://www.typescriptlang.org/docs/handbook/asp-net-core.html | ASP.NET Core
Install ASP.NET Core and TypeScript
First, install ASP.NET Core if you need it. This quick-start guide requires Visual Studio 2015 or 2017.
Next, if your version of Visual Studio does not already have the latest TypeScript, you can install it.
Create a new project
Choose File
Choose New Project (Ctrl + ... | TypeScript: Documentation - ASP.NET Core |
https://www.typescriptlang.org/docs/handbook/modules/appendices/esm-cjs-interop.html | Modules - ESM/CJS Interoperability
It’s 2015, and you’re writing an ESM-to-CJS transpiler. There’s no specification for how to do this; all you have is a specification of how ES modules are supposed to interact with each other, knowledge of how CommonJS modules interact with each other, and a knack for figuring things... | TypeScript: Documentation - Modules - ESM/CJS Interoperability |
https://www.typescriptlang.org/docs/handbook/modules/reference.html | Modules - Reference
Module syntax
The TypeScript compiler recognizes standard ECMAScript module syntax in TypeScript and JavaScript files and many forms of CommonJS syntax in JavaScript files.
There are also a few TypeScript-specific syntax extensions that can be used in TypeScript files and/or JSDoc comments.
Impor... | TypeScript: Documentation - Modules - Reference |
https://www.typescriptlang.org/docs/handbook/modules/guides/choosing-compiler-options.html | Modules - Choosing Compiler Options
I’m writing an app
A single tsconfig.json can only represent a single environment, both in terms of what globals are available and in terms of how modules behave. If your app contains server code, DOM code, web worker code, test code, and code to be shared by all of those, each of t... | TypeScript: Documentation - Modules - Choosing Compiler Options |
https://www.typescriptlang.org/docs/handbook/modules/theory.html | Modules - Theory
Scripts and modules in JavaScript
In the early days of JavaScript, when the language only ran in browsers, there were no modules, but it was still possible to split the JavaScript for a web page into multiple files by using multiple script tags in HTML:
<html>
<head>
<script src="a.js"></script... | TypeScript: Documentation - Modules - Theory |
https://www.typescriptlang.org/docs/handbook/modules/introduction.html | Modules - Introduction
This document is divided into four sections:
The first section develops the theory behind how TypeScript approaches modules. If you want to be able to write the correct module-related compiler options for any situation, reason about how to integrate TypeScript with other tools, or understand ho... | TypeScript: Documentation - Modules - Introduction |
https://www.typescriptlang.org/docs/handbook/variable-declarations.html | Variable Declaration
let and const are two relatively new concepts for variable declarations in JavaScript. As we mentioned earlier, let is similar to var in some respects, but allows users to avoid some of the common “gotchas” that users run into in JavaScript.
const is an augmentation of let in that it prevents re-... | TypeScript: Documentation - Variable Declaration |
https://www.typescriptlang.org/docs/handbook/type-inference.html | Type Inference
In TypeScript, there are several places where type inference is used to provide type information when there is no explicit type annotation. For example, in this code
let x = 3;
let x: number
Try
The type of the x variable is inferred to be number. This kind of inference takes place when initializi... | TypeScript: Documentation - Type Inference |
https://www.typescriptlang.org/docs/handbook/type-compatibility.html | Type Compatibility
Type compatibility in TypeScript is based on structural subtyping. Structural typing is a way of relating types based solely on their members. This is in contrast with nominal typing. Consider the following code:
interface Pet {
name: string;
}
class Dog {
name: string;
}
let pet: Pet;
// OK, b... | TypeScript: Documentation - Type Compatibility |
https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html | Triple-Slash Directives
Triple-slash directives are single-line comments containing a single XML tag. The contents of the comment are used as compiler directives.
Triple-slash directives are only valid at the top of their containing file. A triple-slash directive can only be preceded by single or multi-line comments,... | TypeScript: Documentation - Triple-Slash Directives |
https://www.typescriptlang.org/docs/handbook/symbols.html | Symbols
Starting with ECMAScript 2015, symbol is a primitive data type, just like number and string.
symbol values are created by calling the Symbol constructor.
let sym1 = Symbol();
let sym2 = Symbol("key"); // optional string key
Symbols are immutable, and unique.
let sym2 = Symbol("key");
let sym3 = Symbol("key... | TypeScript: Documentation - Symbols |
https://www.typescriptlang.org/docs/handbook/namespaces-and-modules.html | Namespaces and Modules
This post outlines the various ways to organize your code using modules and namespaces in TypeScript. We’ll also go over some advanced topics of how to use namespaces and modules, and address some common pitfalls when using them in TypeScript.
See the Modules documentation for more information ... | TypeScript: Documentation - Namespaces and Modules |
https://www.typescriptlang.org/docs/handbook/jsx.html | JSX
JSX is an embeddable XML-like syntax. It is meant to be transformed into valid JavaScript, though the semantics of that transformation are implementation-specific. JSX rose to popularity with the React framework, but has since seen other implementations as well. TypeScript supports embedding, type checking, and co... | TypeScript: Documentation - JSX |
https://www.typescriptlang.org/docs/handbook/namespaces.html | Namespaces
A note about terminology: It’s important to note that in TypeScript 1.5, the nomenclature has changed. “Internal modules” are now “namespaces”. “External modules” are now simply “modules”, as to align with ECMAScript 2015’s terminology, (namely that module X { is equivalent to the now-preferred namespace X ... | TypeScript: Documentation - Namespaces |
https://www.typescriptlang.org/docs/handbook/mixins.html | Mixins
Along with traditional OO hierarchies, another popular way of building up classes from reusable components is to build them by combining simpler partial classes. You may be familiar with the idea of mixins or traits for languages like Scala, and the pattern has also reached some popularity in the JavaScript com... | TypeScript: Documentation - Mixins |
https://vuejs.org/guide/extras/reactivity-transform.html#VPContent | Reactivity Transform
Deprecated Experimental Feature
Reactivity Transform was an experimental feature, and has been deprecated. Please read about the reasoning here.
It will eventually be removed from Vue core in a future minor release.
To migrate away from it, check out this command line tool that can automate t... | Reactivity Transform | Vue.js |
https://vuejs.org/guide/extras/animation.html#VPContent | Animation Techniques
Vue provides the <Transition> and <TransitionGroup> components for handling enter / leave and list transitions. However, there are many other ways of using animations on the web, even in a Vue application. Here we will discuss a few additional techniques.
Class-based Animations
For elements ... | Animation Techniques | Vue.js |
https://vuejs.org/guide/extras/web-components.html#VPContent | Vue and Web Components
Web Components is an umbrella term for a set of web native APIs that allows developers to create reusable custom elements.
We consider Vue and Web Components to be primarily complementary technologies. Vue has excellent support for both consuming and creating custom elements. Whether you are ... | Vue and Web Components | Vue.js |
https://vuejs.org/guide/extras/render-function.html#VPContent | Render Functions & JSX
Vue recommends using templates to build applications in the vast majority of cases. However, there are situations where we need the full programmatic power of JavaScript. That's where we can use the render function.
If you are new to the concept of virtual DOM and render functions, make sure ... | Render Functions & JSX | Vue.js |
https://vuejs.org/guide/extras/rendering-mechanism.html#VPContent | Rendering Mechanism
How does Vue take a template and turn it into actual DOM nodes? How does Vue update those DOM nodes efficiently? We will attempt to shed some light on these questions here by diving into Vue's internal rendering mechanism.
Virtual DOM
You have probably heard about the term "virtual DOM", whic... | Rendering Mechanism | Vue.js |
https://vuejs.org/guide/extras/reactivity-transform.html | Reactivity Transform
Deprecated Experimental Feature
Reactivity Transform was an experimental feature, and has been deprecated. Please read about the reasoning here.
It will eventually be removed from Vue core in a future minor release.
To migrate away from it, check out this command line tool that can automate t... | Reactivity Transform | Vue.js |
https://vuejs.org/guide/extras/reactivity-in-depth.html#VPContent | Reactivity in Depth
One of Vue’s most distinctive features is the unobtrusive reactivity system. Component state consists of reactive JavaScript objects. When you modify them, the view updates. It makes state management simple and intuitive, but it’s also important to understand how it works to avoid some common got... | Reactivity in Depth | Vue.js |
https://vuejs.org/guide/extras/composition-api-faq.html#VPContent | Composition API FAQ
TIP
This FAQ assumes prior experience with Vue - in particular, experience with Vue 2 while primarily using Options API.
What is Composition API?
Watch a free video lesson on Vue School
Composition API is a set of APIs that allows us to author Vue components using imported functions instead ... | Composition API FAQ | Vue.js |
https://vuejs.org/guide/extras/ways-of-using-vue.html#VPContent | Ways of Using Vue
We believe there is no "one size fits all" story for the web. This is why Vue is designed to be flexible and incrementally adoptable. Depending on your use case, Vue can be used in different ways to strike the optimal balance between stack complexity, developer experience and end performance.
Stan... | Ways of Using Vue | Vue.js |
https://vuejs.org/guide/typescript/options-api.html#VPContent | TypeScript with Options API
This page assumes you've already read the overview on Using Vue with TypeScript.
TIP
While Vue does support TypeScript usage with Options API, it is recommended to use Vue with TypeScript via Composition API as it offers simpler, more efficient and more robust type inference.
Typing Co... | TypeScript with Options API | Vue.js |
https://vuejs.org/guide/best-practices/security.html#VPContent | Security
Reporting Vulnerabilities
When a vulnerability is reported, it immediately becomes our top concern, with a full-time contributor dropping everything to work on it. To report a vulnerability, please email security@vuejs.org.
While the discovery of new vulnerabilities is rare, we also recommend always usin... | Security | Vue.js |
https://vuejs.org/guide/best-practices/accessibility.html#VPContent | Accessibility
Web accessibility (also known as a11y) refers to the practice of creating websites that can be used by anyone — be that a person with a disability, a slow connection, outdated or broken hardware or simply someone in an unfavorable environment. For example, adding subtitles to a video would help both yo... | Accessibility | Vue.js |
https://vuejs.org/guide/typescript/composition-api.html#VPContent | TypeScript with Composition API
This page assumes you've already read the overview on Using Vue with TypeScript.
Typing Component Props
Using <script setup>
When using <script setup>, the defineProps() macro supports inferring the props types based on its argument:
vue
<script setup lang="ts">
const props = d... | TypeScript with Composition API | Vue.js |
https://vuejs.org/guide/typescript/overview.html#VPContent | Using Vue with TypeScript
A type system like TypeScript can detect many common errors via static analysis at build time. This reduces the chance of runtime errors in production, and also allows us to more confidently refactor code in large-scale applications. TypeScript also improves developer ergonomics via type-ba... | Using Vue with TypeScript | Vue.js |
https://vuejs.org/guide/best-practices/performance.html#VPContent | Performance
Overview
Vue is designed to be performant for most common use cases without much need for manual optimizations. However, there are always challenging scenarios where extra fine-tuning is needed. In this section, we will discuss what you should pay attention to when it comes to performance in a Vue appl... | Performance | Vue.js |
https://vuejs.org/guide/best-practices/production-deployment.html#VPContent | Production Deployment
Development vs. Production
During development, Vue provides a number of features to improve the development experience:
Warning for common errors and pitfalls
Props / events validation
Reactivity debugging hooks
Devtools integration
However, these features become useless in production. Some... | Production Deployment | Vue.js |
https://vuejs.org/guide/scaling-up/ssr.html#VPContent | Server-Side Rendering (SSR)
Overview
What is SSR?
Vue.js is a framework for building client-side applications. By default, Vue components produce and manipulate DOM in the browser as output. However, it is also possible to render the same components into HTML strings on the server, send them directly to the brow... | Server-Side Rendering (SSR) | Vue.js |
https://vuejs.org/guide/scaling-up/routing.html#VPContent | Routing
Client-Side vs. Server-Side Routing
Routing on the server side means the server sending a response based on the URL path that the user is visiting. When we click on a link in a traditional server-rendered web app, the browser receives an HTML response from the server and reloads the entire page with the ne... | Routing | Vue.js |
https://vuejs.org/guide/scaling-up/testing.html#VPContent | Testing
Why Test?
Automated tests help you and your team build complex Vue applications quickly and confidently by preventing regressions and encouraging you to break apart your application into testable functions, modules, classes, and components. As with any application, your new Vue app can break in many ways, ... | Testing | Vue.js |
https://vuejs.org/guide/scaling-up/state-management.html#VPContent | State Management
What is State Management?
Technically, every Vue component instance already "manages" its own reactive state. Take a simple counter component as an example:
vue
<script setup>
import { ref } from 'vue'
// state
const count = ref(0)
// actions
function increment() {
count.value++
}
</script>
... | State Management | Vue.js |
https://vuejs.org/guide/scaling-up/sfc.html#VPContent | Single-File Components
Introduction
Vue Single-File Components (a.k.a. *.vue files, abbreviated as SFC) is a special file format that allows us to encapsulate the template, logic, and styling of a Vue component in a single file. Here's an example SFC:
vue
<script setup>
import { ref } from 'vue'
const greeting = ... | Single-File Components | Vue.js |
https://vuejs.org/guide/built-ins/suspense.html#VPContent | Suspense
Experimental Feature
<Suspense> is an experimental feature. It is not guaranteed to reach stable status and the API may change before it does.
<Suspense> is a built-in component for orchestrating async dependencies in a component tree. It can render a loading state while waiting for multiple nested async ... | Suspense | Vue.js |
https://vuejs.org/guide/built-ins/teleport.html#VPContent | Teleport
Watch a free video lesson on Vue School
<Teleport> is a built-in component that allows us to "teleport" a part of a component's template into a DOM node that exists outside the DOM hierarchy of that component.
Basic Usage
Sometimes we may run into the following scenario: a part of a component's template... | Teleport | Vue.js |
https://vuejs.org/guide/built-ins/keep-alive.html#VPContent | KeepAlive
<KeepAlive> is a built-in component that allows us to conditionally cache component instances when dynamically switching between multiple components.
Basic Usage
In the Component Basics chapter, we introduced the syntax for Dynamic Components, using the <component> special element:
template
<component... | KeepAlive | Vue.js |
https://vuejs.org/guide/built-ins/transition-group.html#VPContent | TransitionGroup
<TransitionGroup> is a built-in component designed for animating the insertion, removal, and order change of elements or components that are rendered in a list.
Differences from <Transition>
<TransitionGroup> supports the same props, CSS transition classes, and JavaScript hook listeners as <Trans... | TransitionGroup | Vue.js |
https://vuejs.org/guide/reusability/plugins.html#VPContent | Plugins
Introduction
Plugins are self-contained code that usually add app-level functionality to Vue. This is how we install a plugin:
js
import { createApp } from 'vue'
const app = createApp({})
app.use(myPlugin, {
/* optional options */
})
A plugin is defined as either an object that exposes an install() m... | Plugins | Vue.js |
https://vuejs.org/guide/built-ins/transition.html#VPContent | Transition
Vue offers two built-in components that can help work with transitions and animations in response to changing state:
<Transition> for applying animations when an element or component is entering and leaving the DOM. This is covered on this page.
<TransitionGroup> for applying animations when an element ... | Transition | Vue.js |
https://vuejs.org/guide/reusability/custom-directives.html#VPContent | Custom Directives
Introduction
In addition to the default set of directives shipped in core (like v-model or v-show), Vue also allows you to register your own custom directives.
We have introduced two forms of code reuse in Vue: components and composables. Components are the main building blocks, while composable... | Custom Directives | Vue.js |
https://vuejs.org/guide/components/async.html#VPContent | Async Components
Basic Usage
In large applications, we may need to divide the app into smaller chunks and only load a component from the server when it's needed. To make that possible, Vue has a defineAsyncComponent function:
js
import { defineAsyncComponent } from 'vue'
const AsyncComp = defineAsyncComponent(()... | Async Components | Vue.js |
https://vuejs.org/guide/reusability/composables.html#VPContent | Composables
TIP
This section assumes basic knowledge of Composition API. If you have been learning Vue with Options API only, you can set the API Preference to Composition API (using the toggle at the top of the left sidebar) and re-read the Reactivity Fundamentals and Lifecycle Hooks chapters.
What is a "Composab... | Composables | Vue.js |
https://vuejs.org/guide/components/provide-inject.html#VPContent | Provide / Inject
This page assumes you've already read the Components Basics. Read that first if you are new to components.
Prop Drilling
Usually, when we need to pass data from the parent to a child component, we use props. However, imagine the case where we have a large component tree, and a deeply nested comp... | Provide / Inject | Vue.js |
https://vuejs.org/guide/components/slots.html#VPContent | Slots
This page assumes you've already read the Components Basics. Read that first if you are new to components.
Watch a free video lesson on Vue School
Slot Content and Outlet
We have learned that components can accept props, which can be JavaScript values of any type. But how about template content? In some ca... | Slots | Vue.js |
https://vuejs.org/guide/components/attrs.html#VPContent | Fallthrough Attributes
This page assumes you've already read the Components Basics. Read that first if you are new to components.
Attribute Inheritance
A "fallthrough attribute" is an attribute or v-on event listener that is passed to a component, but is not explicitly declared in the receiving component's props... | Fallthrough Attributes | Vue.js |
https://vuejs.org/guide/components/v-model.html#VPContent | Component v-model
v-model can be used on a component to implement a two-way binding.
First let's revisit how v-model is used on a native element:
template
<input v-model="searchText" />
Under the hood, the template compiler expands v-model to the more verbose equivalent for us. So the above code does the same as ... | Component v-model | Vue.js |
https://vuejs.org/guide/components/events.html#VPContent | Component Events
This page assumes you've already read the Components Basics. Read that first if you are new to components.
Emitting and Listening to Events
A component can emit custom events directly in template expressions (e.g. in a v-on handler) using the built-in $emit method:
template
<!-- MyComponent -->... | Component Events | Vue.js |
https://vuejs.org/guide/components/props.html#VPContent | Props
This page assumes you've already read the Components Basics. Read that first if you are new to components.
Props Declaration
Vue components require explicit props declaration so that Vue knows what external props passed to the component should be treated as fallthrough attributes (which will be discussed i... | Props | Vue.js |
https://vuejs.org/guide/components/registration.html#VPContent | Component Registration
This page assumes you've already read the Components Basics. Read that first if you are new to components.
Watch a free video lesson on Vue School
A Vue component needs to be "registered" so that Vue knows where to locate its implementation when it is encountered in a template. There are two... | Component Registration | Vue.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.