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
{{ message }}
Repository navigation
Interfaces with all members optional is almost the same as 'any' #9841
Expected behavior:
compiler error '7' is not type AllMembersOptional -- let a: AllMembersOptional = 7;
compiler error 'function: number' is not type AllMembersOptional -- let b: AllMembersOptional = () => 7;
Actual behavior:
no compiler errors or warnings and the following javascript is generated:
vara=7;varb=function(){return7;};
Actual example
Referencing angular.d.ts and converting an angular directive
options parameter cannot a function (or number or string etc).
Just about anything passed in for a parameter of an interface type with all optional parameters will be allowed by typescript
Activity
sandersn commentedon Jul 20, 2016
See this FAQ answer. An interface with all optional properties is similar to an empty interface in this case.
bman61 commentedon Jul 20, 2016
It is similar to an empty (i.e. useless) interface but is it the same?
Per FAQ:
In general, you should never find yourself declaring an interface with no properties.
If never is a good idea, would it make sense to have a compiler flag to issue warnings/errors?
sandersn commentedon Jul 20, 2016
Take a look at #7485 and #3842 -- #7845 is an proposal to fix this based on code from the closed PR #3842.
bman61 commentedon Jul 20, 2016
Looked at both. #3842 definitely discusses the issue and issues with implementing. this helps a lot. thanks