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
Hello. I'm currently writing an Angular1 app and trying to avoid the use of classes. But sometimes it seems a reasonable type-checking can only be achieved either by re-defining the "methods" via interfaces, or by using classes. Let's talk examples:
functionSomeService($someInject){$someInject.run()//will use this latervarout={doThis(){return22},doThat(){return'cool'}}returnout}functionSomeConsumer($scope,SomeService:WhatType){$scope.values=SomeService.doThis()}
While out has an inferred type inside its function scope, I can't access it outside. While inside the function I can get type MyService = typeof out, MyService isn't accessible outside.
Another way to get the desired result there would be to fetch the type of the function returned value. Something like type MyService = typeof SomeService().
Currently my only options seem to be:
either using class style:
Hello. I'm currently writing an Angular1 app and trying to avoid the use of classes. But sometimes it seems a reasonable type-checking can only be achieved either by re-defining the "methods" via interfaces, or by using classes. Let's talk examples:
While
out
has an inferred type inside its function scope, I can't access it outside. While inside the function I can gettype MyService = typeof out
,MyService
isn't accessible outside.Another way to get the desired result there would be to fetch the type of the function returned value. Something like
type MyService = typeof SomeService()
.Currently my only options seem to be:
either using class style:
or by redefining the methods in an interface (+keystrokes)
The text was updated successfully, but these errors were encountered: