You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TypeScript v6 was upgraded in this repo. All unit tests (1111) now pass after fixes.
11
+
12
+
**Why:** TS v6 changed type checker behavior in two ways relevant to tsoa.
13
+
14
+
**Key fixes applied:**
15
+
16
+
1.**`typeResolver.ts``calcMappedType` (line ~210)**: TS v6 `getTypeOfSymbol()` for optional properties in mapped types now includes `undefined` (e.g., `"id" | undefined` instead of `"id"`). Fix: strip the single `undefined` constituent when the property is optional (`SymbolFlags.Optional`) and only one non-undefined type remains.
17
+
18
+
2.**`typeResolver.ts` union TypeNode ordering (line ~65)**: TS v6 UnionType `.types` order may differ from the UnionTypeNode `.types` order. Fix: semantic matching for synthetic TypeNodes (pos === -1) instead of index-based — UndefinedKeyword matches undefined type, non-keyword matches non-null/undefined type.
19
+
20
+
3.**`typeResolver.ts` MappedTypeNode guard (line ~441)**: Skip `symbol.valueDeclaration` when it's a MappedTypeNode, since `.type` on such nodes is the unresolved template.
21
+
22
+
4.**`typeResolver.ts` synthetic node referencer fallback (line ~796)**: For synthetic TypeNodes (pos === -1), fall back to `this.referencer` instead of calling `typeChecker.getTypeFromTypeNode()` which fails.
23
+
24
+
5.**`typeResolver.ts` keyword-indexed accessor (line ~445)**: Pass `type` as 5th arg (referencer) to TypeResolver.
25
+
26
+
6.**`specGenerator2.ts` union type**: Added `typesWithoutUndefined.length === 1` shortcut in `getSwaggerTypeForUnionType` to handle optional enum properties becoming `T | undefined` in TS v6.
27
+
28
+
7.**Test expectations**: Updated `boolValue*` test expectations from `type: 'string'` to `type: 'boolean'` — TS v6 changed conditional type evaluation: `boolean | undefined extends boolean` = `false` (not `true`).
29
+
30
+
**How to apply:** If TS is upgraded again, check these same locations for API behavior changes.
throwUnless(type,newGenerateMetadataError(`Could not determine ${isNumberIndexType ? 'number' : 'string'} index on ${typeChecker.typeToString(typeOfObjectType)}`,typeNode));
throwUnless(symbol,newGenerateMetadataError(`Could not determine the keys on ${typeChecker.typeToString(typeChecker.getTypeFromTypeNode(objectType))}`,typeNode));
`Could not determine the keys on ${typeChecker.typeToString(typeChecker.getTypeFromTypeNode(typeChecker.typeToTypeNode(declaration,undefined,ts.NodeBuilderFlags.NoTruncation)!))}`,
console.warn('Swagger 2.0 does not support union types beyond string literals.\n'+'If you would like to take advantage of this, please change tsoa.json\'s "specVersion" to 3.');
0 commit comments