MCPcopy Create free account
hub / github.com/microsoft/typescript-go / applyToParameterTypes

Method applyToParameterTypes

internal/checker/inference.go:834–860  ·  view source on GitHub ↗
(source *Signature, target *Signature, callback func(s *Type, t *Type))

Source from the content-addressed store, hash-verified

832}
833
834func (c *Checker) applyToParameterTypes(source *Signature, target *Signature, callback func(s *Type, t *Type)) {
835 sourceCount := c.getParameterCount(source)
836 targetCount := c.getParameterCount(target)
837 sourceRestType := c.getEffectiveRestType(source)
838 targetRestType := c.getEffectiveRestType(target)
839 targetNonRestCount := targetCount
840 if targetRestType != nil {
841 targetNonRestCount--
842 }
843 paramCount := targetNonRestCount
844 if sourceRestType == nil {
845 paramCount = min(sourceCount, targetNonRestCount)
846 }
847 sourceThisType := c.getThisTypeOfSignature(source)
848 if sourceThisType != nil {
849 targetThisType := c.getThisTypeOfSignature(target)
850 if targetThisType != nil {
851 callback(sourceThisType, targetThisType)
852 }
853 }
854 for i := range paramCount {
855 callback(c.getTypeAtPosition(source, i), c.getTypeAtPosition(target, i))
856 }
857 if targetRestType != nil {
858 callback(c.getRestTypeAtPosition(source, paramCount, c.isConstTypeVariable(targetRestType, 0) && !someType(targetRestType, c.isMutableArrayLikeType) /*readonly*/), targetRestType)
859 }
860}
861
862func (c *Checker) applyToReturnTypes(source *Signature, target *Signature, callback func(s *Type, t *Type)) {
863 targetTypePredicate := c.getTypePredicateOfSignature(target)

Calls 9

getParameterCountMethod · 0.95
getEffectiveRestTypeMethod · 0.95
getTypeAtPositionMethod · 0.95
getRestTypeAtPositionMethod · 0.95
isConstTypeVariableMethod · 0.95
minFunction · 0.85
someTypeFunction · 0.85
callbackStruct · 0.50

Tested by

no test coverage detected