DefinitelyTyped / DefinitelyTyped

The repository for high quality TypeScript type definitions.
Other
48.63k stars 30.17k forks source link

Aframe is replacing the normal queryselector typings #58796

Open gunhaxxor opened 2 years ago

gunhaxxor commented 2 years ago

I might be misunderstanding something. But. To me, it seems like the aframe types simply replaces the normal typings of the queryselector functions attached to document. Its on these lines:

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/e9be8ea047c2ffd95a8116ee99cca7f027d650cc/types/aframe/index.d.ts#L487-L492

My understanding is that queryselector is now only expected to return an a-entity, not a normal (html)Element which is the original return type. The normal typings for the queryselector is this:

/**
 * Returns the first element that is a descendant of node that matches selectors.
 */
querySelector<K extends keyof HTMLElementTagNameMap>(selectors: K): HTMLElementTagNameMap[K] | null;
querySelector<K extends keyof SVGElementTagNameMap>(selectors: K): SVGElementTagNameMap[K] | null;
querySelector<E extends Element = Element>(selectors: string): E | null;

Preferably, aframe should extend this typing rather than replace it.

I get the following error in vscode: image Curiously, I get no error from terminal when compiling though...

theo97490 commented 1 year ago

I am using Angular and i am experiencing a similar problem caused by this interface.

The Document declaration makes templateRefs ( ie: <div #ref>

) have the wrong type (Entity<...> instead of HTMLDivElement). It does that for every tag except for angular components.

I don't know how to fix this for all use cases but my own fix for now will just be to get my own copy of the d.ts and remove the Document interface for now.