spectator: Missing types for query() method

According to internals.d.ts, the query method has the following types:

    /**
     *
     * @param {Type<T> | string} directiveOrSelector
     * @param {{read}} options
     * @returns {T}
     */
    query<R>(directiveOrSelector: string, options?: {
        read;
    }): Element;
    query<R>(directiveOrSelector: Type<any>, options?: {
        read;
    }): R;

That means that you have to cast the return value of the query method when passing a selector before you can use it. Can’t we change the API so you can do: spectator.query<HTMLElement>('a').click()?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (15 by maintainers)

Most upvoted comments

Thank you. Feel free to give more feedback or issues. 😃

lol, that’s precisely what I did right now.