---
title: "Comment by raddevus on \"Let's code a Virtual DOM!\" | Hashnode"
description: "Are you sure this code works? const app = document.querySelector&lt;HTMLDivElement&gt;(&#39;#app&#39;)!; I think you need to remove &lt;HTMLDivElement&gt; &amp;"
url: "https://hashnode.com/posts/lets-code-a-virtual-dom/6254a9d46386ed96b050b69c/comment/625987b92f84e0d4fc33b935"
---

[Discussion](https://hashnode.com/posts/lets-code-a-virtual-dom/6254a9d46386ed96b050b69c)

Comment [Let's code a Virtual DOM!](https://hashnode.com/posts/lets-code-a-virtual-dom/6254a9d46386ed96b050b69c)

[raddevus](https://hashnode.com/@raddevus)

[Apr 15, 2022](https://hashnode.com/posts/lets-code-a-virtual-dom/6254a9d46386ed96b050b69c/comment/625987b92f84e0d4fc33b935)

Are you sure this code works?

`const app = document.querySelector<HTMLDivElement>('#app')!;`

I think you need to remove <HTMLDivElement> & the ! right before the semicolon.

I think it is supposed to be: `const app = document.querySelector('#app');`

[Krzysztof Kałamarski](https://hashnode.com/@kkalamarski)

[Apr 15, 2022](https://hashnode.com/posts/lets-code-a-virtual-dom/6254a9d46386ed96b050b69c/comment/625987b92f84e0d4fc33b935#reply-62598bd752fb7bd53380d416)

hey [raddevus](https://hashnode.com/@raddevus), thanks for commenting :)

All code I used in this post is a valid TypeScript code.

The `!` is a non-null assertion operator - [see the docs](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#non-null-assertion-operator-postfix-).

But you are right, if you want to run this code in the browser you need to remove typescript-specific syntax (like type annotation and `!`)

[raddevus](https://hashnode.com/@raddevus)

[Apr 15, 2022](https://hashnode.com/posts/lets-code-a-virtual-dom/6254a9d46386ed96b050b69c/comment/625987b92f84e0d4fc33b935#reply-6259c0432f84e0d4fc33bfe6)

[Krzysztof Kałamarski](https://hashnode.com/@kkalamarski) Ahh...TypeScript Ok, got it.
