Skip to content

TS2344 with generics of querySelector and querySelectorAll #21405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
HolgerJeromin opened this issue Jan 25, 2018 · 2 comments
Closed

TS2344 with generics of querySelector and querySelectorAll #21405

HolgerJeromin opened this issue Jan 25, 2018 · 2 comments
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@HolgerJeromin
Copy link
Contributor

TypeScript Version: 2.6.3

Code

let result = document.querySelector('div'); // result is HTMLDivElement
//  compiles 

let result1 = document.querySelector<HTMLDivElement>('div'); // result1 is HTMLDivElement
// error TS2344: Build:Type 'HTMLDivElement' does not satisfy the constraint '"symbol" | "object" | "track" | "progress" | "a" | "applet" | "area" | "audio" | "base" | "basefo...'.

let result2 = document.querySelector<HTMLDivElement>('div[id][data-foo]');// result1 is HTMLDivElement
//error TS2344: Build:Type 'HTMLDivElement' does not satisfy the constraint '"symbol" | "object" | "track" | "progress" | "a" | "applet" | "area" | "audio" | "base" | "basefo...'.

let result3 = document.querySelector('div[id][data-foo]'); // result3 is Element 8-/
// compiles

Expected behavior:
All four lines should compile. VS highlighting and playground do not show errors.

Actual behavior:
TS2344 is shown, compile aborts.

querySelectorAll has the same problem.

introduced in #12568

@aluanhaddad
Copy link
Contributor

Works fine in nightly.

@ghost ghost added Fixed A PR has been merged for this issue Bug A bug in TypeScript labels Jan 25, 2018
@HolgerJeromin
Copy link
Contributor Author

@aluanhaddad thanks for testing next!

@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

2 participants