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
fix: distinguish duplicate model declarations from real model conflicts
CheckModelUnicity treated any two same-named declarations with different
file positions as conflicting models. Valid TypeScript programs routinely
contain duplicate declarations that describe the same model:
- one file reached through two paths (symlinks, package manager links)
- byte-identical copies of a file (pnpm injected workspace packages)
- a built declaration file (.d.ts + .d.ts.map) next to its source file
- verbatim copies of a declaration (common with generated API clients)
These are now recognized as the same logical declaration instead of
throwing 'Found 2 different model definitions'.
Additionally, a declaration marked with @tsoaModel is honored again as
the canonical model for its name across files: same-named declarations
in other files resolve to the designated declaration, restoring the
documented deduplication behavior that regressed in #1498.
Genuinely different same-named declarations without a designation still
throw, now with a hint about @tsoaModel.
Closes#1650Closes#1853Closes#1860
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
thrownewGenerateMetadataError(`Multiple models for ${refName} marked with '@tsoaModel'; '@tsoaModel' should only be applied to one model.`);
258
+
}
259
+
thrownewError(
260
+
`Found 2 different model definitions for model ${refName}: orig: ${printable(origPositions)}, act: ${printable(positions)}. `+
261
+
`If both definitions describe the same model, mark the canonical declaration with a '@tsoaModel' JSDoc tag; otherwise rename one of the types to resolve the collision.`,
262
+
);
263
+
}
264
+
}
265
+
}
266
+
267
+
/**
268
+
* Returns the declarations marked with '@tsoaModel' for the given type name anywhere in the
269
+
* program. Such a declaration is the canonical model for that name: same-named declarations in
270
+
* other files resolve to it instead of raising a model definition conflict. Designations that
271
+
* are the same logical declaration reached through different files (e.g. a marked source file
272
+
* whose built declaration file, which keeps the JSDoc, is also in the program) are deduplicated.
0 commit comments