ember-simple-auth
ember-simple-auth copied to clipboard
TypeScript definitions for injected session service
I'm trying to import this service:
import EmberSimpleAuthSession from 'ember-simple-auth/addon/services/session';
So that I can use it as a type:
export default class ShowProjectController extends Controller {
@service
session!: EmberSimpleAuthSession
...according to the e-typescript documentation.
But TypeScript can't find the definitions. So, I was able to pull this in and have better luck: https://github.com/Gavant/octane-bootcamp/blob/master/types/ember-simple-auth/services/session.d.ts
But, I'd hate for this file to fall out of sync to any changes across versions.
Separately, I know there's some churn on how to deal with Mixins, but we can at least type parts of the addon. Is there something I'm missing?
It's been a year on this issue. Any updates here?
just so you guys now, this is still an up-to-date issue in 2021 :)
I'd be interesting in contributing type definitions for ESA if there is interest from the maintainers.
@marcoow @BobrImperator Any opinions on how best to add type definitions?
An index.d.ts file would be the most straightforward to add but might end up being difficult to maintain. Since there is already extensive JSDoc we could look at generating type definitions from the JSDoc comments, but this will require some new CI tooling to make sure the JSDoc types are correct. I also have concerns that the base class implementations often don't match the JSDoc comments (since the JSDoc represents how subclasses should implemented, rather than representing the implementations of the base classes). Fixing that particular issue may require a decent amount of code changes to the base class implementations.
There is also the possibility of full typescript conversion of the addon, although I'm not sure if there would be interest in that from the maintainers.
2023, still an open issue, anyone have the solution yet?
@marcoow any plans to add types?
I don't think anyone on our side is currently planning to do this tbh but we'd be happy to merge a PR!
Perhaps someone could PR in the Gavant types linked above?
I have a much more robust set of types we've been using internally at CrowdStrike. I'll see if I can get those PR'd as an index.d.ts
PR open, feedback welcome 😃 https://github.com/mainmatter/ember-simple-auth/pull/2514
Thanks for pinging the issue 👍 I've been looking into refactoring the codebase to use tracked and native classes. I think it could be possible to use typescript at that point or at least do some groundwork into making it easier to type.