TypeScript Compiler Diagnostics

TS2314: Generic type requires type arguments

A generic type alias has a required type parameter and no default. Unlike a generic function call, a bare reference to this alias does not infer its type argument from the initializer. Specify the argument or design a meaningful default when that is part of the API. Baseline: TypeScript 5.8.3 with the shown configuration. Reproduce in one directory and create the corrected project in another. The diagnostic can have other causes; inspect its location and message before choosing a correction. Both projects keep strict checking enabled.

Formal Syntax & Structure

typescript syntaxtypescript
TS2314 (compiler diagnostic code, not TypeScript syntax)

Working Example

Example Snippettypescript
// INTENTIONALLY INVALID — reproduce// File: tsconfig.json (omit this label){  "compilerOptions": {    "strict": true,    "target": "ES2022",    "module": "CommonJS",    "types": [],    "lib": [      "ES2022",      "DOM"    ],    "noEmitOnError": true,    "outDir": "dist"  },  "files": [    "main.ts"  ]}
// File: main.ts (omit this label)type Box<T> = { value: T };const box: Box = { value: 7 };
// Run: tsc -p . --pretty false// Expected: TS2314; no output emitted.
// CORRECTED PROJECT — separate directory// File: tsconfig.json (omit this label){  "compilerOptions": {    "strict": true,    "target": "ES2022",    "module": "CommonJS",    "types": [],    "lib": [      "ES2022",      "DOM"    ],    "noEmitOnError": true,    "outDir": "dist"  },  "files": [    "main.ts"  ]}
// File: main.ts (omit this label)type Box<T> = { value: T };const box: Box<number> = { value: 7 };console.log(box.value);
// Run: tsc -p . --pretty false// Expected: no diagnostics.// Run: node dist/main.js// Expected stdout: 7
TypeScript Reference