Adds support for type parameter defaults by rbuckton · Pull Request #13487 · microsoft/TypeScript
@RyanCavanaugh: this is my take on refreshing the genericDefaults PR. It should resolve the open items you had on #6354 regarding checking defaults against constraints. I also added missing support for typeToString and the declaration emitter. Please let me know if you can suggest any additional tests.
@mhegazy: when we discussed this, I suggested that interface declarations that have defaults must have identical defaults, allowing you to mix declarations with and without defaults:
interface X<A, B> {} interface X<A, B = number> {}
However, this PR does not reflect that suggestion and is more strict, requiring all declarations to have identical defaults as well. It seems more consistent and we can loosen this restriction at any point if we so choose.
@ahejlsberg: The getResolvedDefault function in checker.ts is somewhat similar to getResolvedBaseConstraint. However, I chose to reuse the existing pushTypeResolution/popTypeResolution functions to perform circularity checks. Is there a specific advantage for getResolvedBaseConstraint to have its own circularity logic? Would you recommend I use that approach for getResolvedDefault, or would it make sense to modify getResolvedBaseConstraint to use the type-resolution functions?