or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

ast-node-types.mdindex.mdparser-configuration.mdtoken-types.mdtypescript-estree.mdtypescript-libraries.md

typescript-libraries.mddocs/

0

# TypeScript Libraries

1

2

Union type defining all available TypeScript library targets for compilation and type checking. These library targets control which built-in type definitions are available during TypeScript compilation.

3

4

## Capabilities

5

6

### Lib Type

7

8

Complete union type of all TypeScript library targets.

9

10

```typescript { .api }

11

type Lib =

12

// Core ECMAScript libraries

13

| 'es5'

14

| 'es6'

15

| 'es7'

16

| 'es2015'

17

| 'es2015.collection'

18

| 'es2015.core'

19

| 'es2015.generator'

20

| 'es2015.iterable'

21

| 'es2015.promise'

22

| 'es2015.proxy'

23

| 'es2015.reflect'

24

| 'es2015.symbol'

25

| 'es2015.symbol.wellknown'

26

| 'es2016'

27

| 'es2016.array.include'

28

| 'es2016.full'

29

| 'es2016.intl'

30

| 'es2017'

31

| 'es2017.arraybuffer'

32

| 'es2017.date'

33

| 'es2017.full'

34

| 'es2017.intl'

35

| 'es2017.object'

36

| 'es2017.sharedmemory'

37

| 'es2017.string'

38

| 'es2017.typedarrays'

39

| 'es2018'

40

| 'es2018.asyncgenerator'

41

| 'es2018.asynciterable'

42

| 'es2018.full'

43

| 'es2018.intl'

44

| 'es2018.promise'

45

| 'es2018.regexp'

46

| 'es2019'

47

| 'es2019.array'

48

| 'es2019.full'

49

| 'es2019.intl'

50

| 'es2019.object'

51

| 'es2019.string'

52

| 'es2019.symbol'

53

| 'es2020'

54

| 'es2020.bigint'

55

| 'es2020.date'

56

| 'es2020.full'

57

| 'es2020.intl'

58

| 'es2020.number'

59

| 'es2020.promise'

60

| 'es2020.sharedmemory'

61

| 'es2020.string'

62

| 'es2020.symbol.wellknown'

63

| 'es2021'

64

| 'es2021.full'

65

| 'es2021.intl'

66

| 'es2021.promise'

67

| 'es2021.string'

68

| 'es2021.weakref'

69

| 'es2022'

70

| 'es2022.array'

71

| 'es2022.error'

72

| 'es2022.full'

73

| 'es2022.intl'

74

| 'es2022.object'

75

| 'es2022.regexp'

76

| 'es2022.string'

77

| 'es2023'

78

| 'es2023.array'

79

| 'es2023.collection'

80

| 'es2023.full'

81

| 'es2023.intl'

82

| 'es2024'

83

| 'es2024.arraybuffer'

84

| 'es2024.collection'

85

| 'es2024.full'

86

| 'es2024.object'

87

| 'es2024.promise'

88

| 'es2024.regexp'

89

| 'es2024.sharedmemory'

90

| 'es2024.string'

91

| 'esnext'

92

| 'esnext.array'

93

| 'esnext.asynciterable'

94

| 'esnext.bigint'

95

| 'esnext.collection'

96

| 'esnext.decorators'

97

| 'esnext.disposable'

98

| 'esnext.error'

99

| 'esnext.float16'

100

| 'esnext.full'

101

| 'esnext.intl'

102

| 'esnext.iterator'

103

| 'esnext.object'

104

| 'esnext.promise'

105

| 'esnext.regexp'

106

| 'esnext.sharedmemory'

107

| 'esnext.string'

108

| 'esnext.symbol'

109

| 'esnext.weakref'

110

111

// Platform libraries

112

| 'dom'

113

| 'dom.asynciterable'

114

| 'dom.iterable'

115

| 'webworker'

116

| 'webworker.asynciterable'

117

| 'webworker.importscripts'

118

| 'webworker.iterable'

119

| 'scripthost'

120

121

// Feature libraries

122

| 'decorators'

123

| 'decorators.legacy'

124

| 'lib';

125

```

126

127

**Usage Examples:**

128

129

```typescript

130

import { Lib, ParserOptions } from "@typescript-eslint/types";

131

132

// Basic modern web application

133

const webAppLibs: Lib[] = [

134

'es2022',

135

'dom',

136

'dom.iterable'

137

];

138

139

// Node.js server application

140

const nodeAppLibs: Lib[] = [

141

'es2021',

142

'es2021.promise'

143

];

144

145

// Configure parser with specific libraries

146

const parserOptions: ParserOptions = {

147

lib: [

148

'es2023', // Latest stable ECMAScript features

149

'dom', // Browser DOM APIs

150

'dom.iterable', // Iterable DOM collections

151

'webworker', // Web Worker APIs

152

'decorators', // Decorator support

153

]

154

};

155

156

// Check if a library is ECMAScript-related

157

function isECMAScriptLib(lib: Lib): boolean {

158

return lib.startsWith('es') || lib.startsWith('esnext');

159

}

160

161

// Get full feature set for a specific year

162

function getFullLibForYear(year: number): Lib[] {

163

const baseLib = `es${year}` as Lib;

164

const fullLib = `es${year}.full` as Lib;

165

return [baseLib, fullLib];

166

}

167

```

168

169

## Library Categories

170

171

### ECMAScript Core Libraries

172

173

Base ECMAScript version libraries:

174

175

- **es5**: ECMAScript 5 (2009) - Basic JavaScript

176

- **es6/es2015**: ECMAScript 2015 - Classes, modules, arrow functions

177

- **es2016-es2024**: Annual ECMAScript releases with incremental features

178

- **esnext**: Cutting-edge ECMAScript features (use with caution)

179

180

### ECMAScript Feature Libraries

181

182

Granular feature libraries for specific ECMAScript capabilities:

183

184

- **Collection Libraries**: `es2015.collection`, `es2023.collection` - Map, Set, WeakMap, WeakSet

185

- **Promise Libraries**: `es2015.promise`, `es2021.promise` - Promise APIs and enhancements

186

- **Array Libraries**: `es2016.array.include`, `es2019.array`, `es2022.array` - Array methods

187

- **String Libraries**: `es2017.string`, `es2019.string`, `es2022.string` - String methods

188

- **Symbol Libraries**: `es2015.symbol`, `es2019.symbol` - Symbol functionality

189

- **Async Libraries**: `es2018.asyncgenerator`, `es2018.asynciterable` - Async iteration

190

191

### Platform Libraries

192

193

Environment-specific APIs:

194

195

- **DOM Libraries**:

196

- `dom` - Browser DOM APIs (Document, Element, etc.)

197

- `dom.iterable` - Iterable DOM collections (NodeList, HTMLCollection)

198

- `dom.asynciterable` - Async iterable DOM APIs

199

- **Web Worker Libraries**:

200

- `webworker` - Web Worker global scope

201

- `webworker.iterable` - Iterable APIs in workers

202

- `webworker.importscripts` - ImportScripts functionality

203

- **Script Host**: `scripthost` - Windows Script Host APIs

204

205

### Feature Libraries

206

207

Specific language features:

208

209

- **Decorators**:

210

- `decorators` - Stage 3 decorator proposal

211

- `decorators.legacy` - Legacy experimental decorators

212

- **Special**: `lib` - Core library functionality

213

214

### Full Libraries

215

216

Comprehensive feature sets for specific versions:

217

218

- **es2016.full**, **es2017.full**, etc. - Complete feature set for that ECMAScript version

219

- **esnext.full** - All cutting-edge features

220

221

**Common Library Combinations:**

222

223

```typescript

224

// Modern web application (React/Vue/Angular)

225

const modernWebLibs: Lib[] = [

226

'es2022',

227

'dom',

228

'dom.iterable',

229

'es2022.array',

230

'es2022.string'

231

];

232

233

// Node.js backend service

234

const nodeLibs: Lib[] = [

235

'es2021',

236

'es2021.promise',

237

'es2021.string',

238

'es2021.weakref'

239

];

240

241

// Browser extension

242

const extensionLibs: Lib[] = [

243

'es2020',

244

'dom',

245

'webworker',

246

'scripthost'

247

];

248

249

// TypeScript with decorators

250

const decoratorLibs: Lib[] = [

251

'es2023',

252

'decorators',

253

'dom'

254

];

255

256

// Legacy browser support

257

const legacyLibs: Lib[] = [

258

'es5',

259

'dom'

260

];

261

262

// Cutting-edge features (experimental)

263

const experimentalLibs: Lib[] = [

264

'esnext.full',

265

'esnext.decorators',

266

'esnext.disposable',

267

'dom'

268

];

269

```

270

271

## Library Selection Guidelines

272

273

### Version Selection Strategy

274

275

1. **Start with base version**: Choose the oldest ECMAScript version your target environments support

276

2. **Add specific features**: Include only the feature libraries you actually use

277

3. **Include platform APIs**: Add `dom` for browsers, omit for Node.js

278

4. **Consider future features**: Use `esnext` libraries carefully, prefer stable versions

279

280

### Common Combinations

281

282

- **Modern Web**: `['es2022', 'dom', 'dom.iterable']`

283

- **Node.js Server**: `['es2021', 'es2021.promise']`

284

- **Legacy Support**: `['es5', 'dom']`

285

- **TypeScript with Decorators**: `['es2023', 'decorators', 'dom']`

286

- **Web Worker**: `['es2020', 'webworker', 'webworker.iterable']`

287

288

### Performance Considerations

289

290

- Including more libraries increases TypeScript's memory usage

291

- Only include libraries for APIs you actually use

292

- Prefer specific feature libraries over `.full` libraries when possible

293

- Test library combinations with your target environments