Skip to content

unexpected return type when calling document.querySelector with a non string type argument #10518

Closed
@goser

Description

@goser

TypeScript Version: v2.0.0-beta

Code

<HTMLDivElement>document.querySelector(<any>'div');

Expected behavior:

  1. Get "Element" as return type like in previous versions.
    or
  2. Get an error for not using a string as argument.

Actual behavior:
Compiler outputs following error:
test.ts(1,1): error TS2352: Type 'HTMLAnchorElement' cannot be converted to type 'HTMLDivElement'.
Property 'align' is missing in type 'HTMLAnchorElement'.

I think this has something to do with the changes for #8114.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions