Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

TypeScript Definition #4

Closed
dmzza opened this issue Apr 2, 2019 · 3 comments · Fixed by #20
Closed

TypeScript Definition #4

dmzza opened this issue Apr 2, 2019 · 3 comments · Fixed by #20
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@dmzza
Copy link
Contributor

dmzza commented Apr 2, 2019

Could you add a TypeScript definition file for this add-on?

I'm new to TypeScript, so this could be wrong, but this is what I used:

export const name: string;

export default class Modifier {
  element: Element
  didInsertElement(positional?: Array<any>, named?: Object): void
  didRecieveArguments(positional?: Array<any>, named?: Object): void
  didUpdateArguments(positional?: Array<any>, named?: Object): void
  willDestroyElement(positional?: Array<any>, named?: Object): void

  static modifier(klass: typeof Modifier): any
}
@sukima
Copy link
Owner

sukima commented Apr 4, 2019

I haven't a clue about TypeScript. I more new then you are.

Does this work for you? I'm happy to just merge it as is. Can I do that?

@sukima sukima added enhancement New feature or request help wanted Extra attention is needed labels Apr 4, 2019
@dmzza
Copy link
Contributor Author

dmzza commented Apr 5, 2019

Yes, it works for me, but now I've refined this TypeScript definition to be even more specific. I'll make a PR for it.

@dmzza dmzza mentioned this issue Apr 5, 2019
2 tasks
@josemarluedke
Copy link

For reference: here is the types I'm using with the latest changes for ember-class-based-modifier.

declare module 'ember-class-based-modifier' {
  interface Args<TNamed, TPositional> {
    named: TNamed;
    positional: TPositional;
  }

  export default class Modifier<TNamed = object, TPositional = unknown[]> {
    public args: Args<TNamed, TPositional>;

    public element: HTMLElement | SVGElement;
    public isDestroyed: boolean;
    public isDestroying: boolean;

    public constructor(owner: unknown, args: Args<TNamed, TPositional>);

    public didInstall(): void;
    public didReceiveArguments(): void;
    public didUpdateArguments(): void;
    public willRemove(): void;
    public willDestroy(): void;
  }
}

@dmzza dmzza mentioned this issue Sep 20, 2019
2 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants