The Error
Generic type 'Array<T>' requires 1 type argument(s). ts(2314)
This fires whenever you reference a generic type โ Array, Promise, Map, Set, or any custom generic โ without specifying what type it holds. TypeScript can't compile what it can't reason about.
Why It Happens
Every generic type carries at least one type parameter โ that's the T in Array<T>. Skip it, and TypeScript is left guessing what the array actually contains. It won't guess. It errors out instead.
Common triggers:
- Writing a raw generic in a type position:
let items: Array - Using built-in generics (
Promise,Map,Set,Record) without type args - Referencing a custom generic class or interface without its type parameters
- Copy-pasting Java or C# code โ raw types are valid there, not in TypeScript
Step-by-Step Fix
1. Built-in generics: always supply the type argument
Start here โ it's the most common source of ts(2314). Add the concrete type inside angle brackets:
// โ Broken
let items: Array;
let pending: Promise;
let lookup: Map;
let ids: Set;
// โ
Fixed
let items: Array<string>; // or: string[]
let pending: Promise<void>; // or: Promise<User>, Promise<number>, โฆ
let lookup: Map<string, number>;
let ids: Set<number>;
2. Function parameters and return types
Function signatures need type args too. No exceptions:
// โ Broken
function processItems(items: Array): void {}
async function fetchUser(): Promise {}
// โ
Fixed
function processItems(items: Array<string>): void {}
async function fetchUser(): Promise<User> {}
3. Custom generic types
Built your own generic interface? Wherever you use it as a type annotation, fill in the type parameters:
interface Repository<T> {
findById(id: number): T;
save(entity: T): void;
}
// โ Broken
const userRepo: Repository;
// โ
Fixed
const userRepo: Repository<User>;
4. Type aliases and generics
type ApiResponse<T> = {
data: T;
status: number;
message: string;
};
// โ Broken
function handleResponse(res: ApiResponse) {}
// โ
Fixed
function handleResponse(res: ApiResponse<unknown>) {}
// or be specific:
function handleResponse(res: ApiResponse<User[]>) {}
5. When you genuinely don't know the type: use unknown or a type parameter
Reaching for any is tempting โ but it turns off type checking entirely. Make the function generic instead, and let callers supply the type:
// โ Avoid โ disables type checking
function wrap(value: any): Array<any> { return [value]; }
// โ
Better โ the type flows through
function wrap<T>(value: T): Array<T> { return [value]; }
// TypeScript infers the right type at each call site
const nums = wrap(42); // number[]
const strs = wrap('hello'); // string[]
6. Stricter config: noImplicitAny
Enabled strict or noImplicitAny in tsconfig.json and suddenly seeing ts(2314) in dozens of files? That's expected โ strict mode surfaces raw generics that were quietly ignored before. Fix each one individually. Don't loosen the config just to silence them.
// tsconfig.json
{
"compilerOptions": {
"strict": true // enables noImplicitAny + other safety flags
}
}
Verify the Fix
Run the TypeScript compiler in no-emit mode:
npx tsc --noEmit
Clean exit โ no output, exit code 0 โ means you're done. In VS Code, open the Problems panel with Ctrl+Shift+M; the ts(2314) entries disappear as soon as you save the file.
Quick Reference
Array<T>โArray<string>,string[],Array<unknown>Promise<T>โPromise<void>for no return value,Promise<YourType>otherwiseMap<K, V>โ two args required:Map<string, number>Set<T>โ one arg:Set<string>- Custom generics โ match the number of type parameters in the definition
- Unknown content โ prefer
unknownoverany; let callers narrow the type themselves

