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
Additional context
If I specify return type explicitly it works as expected
functionfn(input: {test1: number;test2: string}): {a: number;b: string}{return{a: 2,b: 'str',};}exportfunctionfn2(input: {test1: number;test2: string}): {a: number;b: string}{// this is the only change as return type is explicit nowconst{ a }=fn({test1: 25,test2: 'test'});return{
a,b: 'str',};}
The text was updated successfully, but these errors were encountered:
I'm afraid it might be impossible to fix this issue in general. The reason is duck typing. On the compiler level we just don't know if your object is related somehow (or declares anyhow) to a returned type. After quick look into the state of the program I didn't find a strong relation between a returned type and a type of a variable. Yes, we can try to rely of symbols of both of them, but even if they are the same now doesn't mean that they will be the same in the next versions and due duck typing they shouldn't be the same.
That's because const result has no relation to a returned value's type, they are similar (or the same, or narrowed one from another) in terms of duck typing but they aren't the same (even adding a unnamed returned type to a function might break it).
Probably after #14 it could be a bit better since the tool won't rely on types and will use names only, but it won't produce the same level of minifying.
I'll partially fix this issue soon, but this thing is a bit dangerous and I'd say that it's better to specify an API explicitly when it's possible.
Bug report
When I do not specify return type to public functions the returning literal object is transformed to the object with internal properties.
Input code
Expected output
Actual output
Additional context
If I specify return type explicitly it works as expected
The text was updated successfully, but these errors were encountered: