From b4eacf434ca152d393272fc91743d226e651ce1d Mon Sep 17 00:00:00 2001 From: Qudus Olawale Bashiru <66824020+olawalethefirst@users.noreply.github.com> Date: Sun, 9 Nov 2025 08:32:45 +0100 Subject: [PATCH] docs: expand TypeScript generics section with examples of invalid type arguments New code examples showing a typical TypeScript mistake of passing incompatible types that violates a generics' constraint. --- .../documentation/copy/en/handbook-v2/More on Functions.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/documentation/copy/en/handbook-v2/More on Functions.md b/packages/documentation/copy/en/handbook-v2/More on Functions.md index 4d40edb5bada..fe48a264dbdd 100644 --- a/packages/documentation/copy/en/handbook-v2/More on Functions.md +++ b/packages/documentation/copy/en/handbook-v2/More on Functions.md @@ -190,6 +190,8 @@ const longerArray = longest([1, 2], [1, 2, 3]); const longerString = longest("alice", "bob"); // Error! Numbers don't have a 'length' property const notOK = longest(10, 100); +// Error! An array of numbers and a string can't be compared +const alsoNotOK = longest([1, 2], 'alice'); ``` There are a few interesting things to note in this example. @@ -887,3 +889,4 @@ const f3 = function (): void { For more on `void` please refer to these other documentation entries: - [FAQ - "Why are functions returning non-void assignable to function returning void?"](https://github.com/Microsoft/TypeScript/wiki/FAQ#why-are-functions-returning-non-void-assignable-to-function-returning-void) +