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
Expected behavior:
Whether the usage is inside the same package (.ts file referenced) or another package (.d.ts file referenced) AppleArgs should be [string|number].
Actual behavior:
If the usage is in the same package, AppleArgs is [string|number].
If the usage is in a different package, AppleArgs is [number].
Related Issues: I understand that conditional types (like ConstructorParameters) use the last overload. What I believe is a "bug" here is that the emitted declaration file results in different behavior when the class is referenced from another package vs when it is referenced from the same package. My expectation is that the behavior will be the same in either case.
The text was updated successfully, but these errors were encountered:
Like you, I'm most surprised that the behavior differs - the implementation signature is (by design) not considered one of the overloads, so if what you've put under "generated declaration file" is accurate, ConstructorParameters<typeof Apple> should be the same type regardless of whether it occurs inside or outside of the implementing package.
For the sake of conditional types, I believe that the implementation signature is considered when it comes to "picking the last overload". This is different from other parts of tsc where the implementation signature isn't considered.
Hmm, I just realized that I cannot reproduce the desired/expected behavior in Playground, so my issue may be something else. I'm going to close this for now since I don't have a clear repro case that exhibits different behavior between .d.ts and .ts, though the current behavior is frustrating and confusing, I think it is "by design".
TypeScript Version: 3.6.3
Search Terms:
conditional type overload declaration file
Code
Typescript file:
Generated declaration file:
Usage:
Expected behavior:
Whether the usage is inside the same package (.ts file referenced) or another package (.d.ts file referenced)
AppleArgs
should be[string|number]
.Actual behavior:
If the usage is in the same package,
AppleArgs
is[string|number]
.If the usage is in a different package,
AppleArgs
is[number]
.Playground Link: https://www.typescriptlang.org/play/?ssl=1&ssc=1&pln=6&pc=1#code/CYUwxgNghgTiAEkoGdnwIIAdMQQbwCh5jEB7AO2QBcYBXMK0mACigC55qYBLcgcwCUREmApd6jFu3jlaAWwBGIGEIC+BKgE9MCLDhDoYfNAF54AYTE0JTAAqwockFWXIAPFp2kAZhmy4APgIgA
Not a great playground link since this is an issue with declaration emission.
Related Issues: I understand that conditional types (like
ConstructorParameters
) use the last overload. What I believe is a "bug" here is that the emitted declaration file results in different behavior when the class is referenced from another package vs when it is referenced from the same package. My expectation is that the behavior will be the same in either case.The text was updated successfully, but these errors were encountered: