Skip to content
This repository was archived by the owner on Sep 1, 2026. It is now read-only.
This repository was archived by the owner on Sep 1, 2026. It is now read-only.

Cannot find name html element. #3638

Closed

Description

Extension Version

0.20260428.1

VS Code Version

1.117.0

Operating system Version

MacOS 26.4.1

Steps to reproduce

Honestly no idea how it triggers exactly, but we have a .tsx and some div closing tags seem to trigger a Cannot find name 'div'. ts(2304)

A restart of the LSP helped, but I assume it's still something you guys want to be aware of

Issue

Expect Typescript to recognize the closing div tag as a valid element

Activity

  1. added
    Domain: Editor
    on Apr 28, 2026
  2. jakebailey commented on Apr 28, 2026

    @jakebailey
    Member

    We would really need a repro, or at least some logs

  3. Netail commented on Apr 28, 2026

    @Netail
    Author

    We would really need a repro, or at least some logs

    The issue is that it has happened in mulitple files and not consistent at all. I have no idea how to repoduce it, it just randomly happens at some point in the TSX file I am working in. And tried backtracing my steps. I could try to get some logs

  4. changed the title [-]Cannot find name 'div'.[/-] [+]Cannot find name html element.[/+] on Apr 29, 2026
  5. Netail commented on Apr 30, 2026

    @Netail
    Author

    The logs:

    typescript-go.log

    It happened by doing nothing, so I had a big TSX file open and just waited. And then out of nowhere it started throwing the error on a html element.

  6. RyanCavanaugh commented on May 6, 2026

    @RyanCavanaugh
    Member

    Log does indeed show something weird happen, but it's super hard to guess what's going on. Log + repo might be enough to reconstruct what's happening.

  7. Netail commented on May 6, 2026

    @Netail
    Author

    Log does indeed show something weird happen, but it's super hard to guess what's going on. Log + repo might be enough to reconstruct what's happening.

    Sadly I have no idea how to reproduce it, I've tried many things. It's almost as if the LSP randomly tries to re-index all types, but fails to index react types. Perhaps something with pnpm, will try a few more things

  8. Netail commented on May 6, 2026

    @Netail
    Author

    Okay, was able to reproduce it in https://github.com/Netail/repro-typescript-go-unknown-html-element. In the page.tsx (ts6 + tsgo vscode extension) Now I have to figure out the repro steps

  9. Netail commented on May 6, 2026

    @Netail
    Author
    1. Clone repo
    2. pnpm install in the repo
    3. Open the repo in vscode with the tsgo preview vscode extension
    4. Open apps\my-app\app\page.tsx
    5. Close that file, then open the root package.json
    6. Close the root package.json, then open apps\my-app\app\page.tsx again

    Was able to reproduce it will a fresh install + pnpm install, without running pnpm dev once or making changes in files

    Desktop.2026.05.07.-.00.24.09.01.mp4
  10. RyanCavanaugh commented on May 6, 2026

    @RyanCavanaugh
    Member

    Confirmed locally, investigating. Great repro, thanks!

  11. Netail commented on May 6, 2026

    @Netail
    Author

    Confirmed locally, investigating. Great repro, thanks!

    Awesome, thanks Ryan! Good luck :)

  12. RyanCavanaugh commented on May 7, 2026

    @RyanCavanaugh
    Member

    fourslash test

    package fourslash_test
    
    import (
    	"testing"
    
    	"github.com/microsoft/typescript-go/internal/fourslash"
    	"github.com/microsoft/typescript-go/internal/testutil"
    )
    
    // Regression test for https://github.com/microsoft/typescript-go/issues/3638
    //
    // A `textDocument/hover` on a JSX intrinsic element used to cause the
    // subsequent `textDocument/diagnostic` pull to spuriously report
    // TS2304: Cannot find name 'div'.
    func TestHoverThenDiagnosticsJsxIntrinsic(t *testing.T) {
    	t.Parallel()
    	defer testutil.RecoverAndFail(t, "Panic on fourslash test")
    	const content = `// @Filename: /tsconfig.json
    { "compilerOptions": { "strict": true, "jsx": "preserve" } }
    // @Filename: /jsx.d.ts
    declare namespace JSX {
        interface Element { }
        interface IntrinsicElements {
            div: any
        }
    }
    // @Filename: /file.tsx
    export default function Home() {
        return <di/*1*/v>hi</div>;
    }`
    	f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
    	defer done()
    	// Hover on the intrinsic element first...
    	f.VerifyQuickInfoAt(t, "1", "(property) JSX.IntrinsicElements.div: any", "")
    	// ...then a subsequent diagnostic pull must not invent a TS2304 for `div`.
    	f.VerifyNoErrors(t)
    }
  13. jakebailey commented on May 7, 2026

    @jakebailey
    Member

    I suspect #3435 would fix this by way of not sharing checkers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Domain: EditorNeeds Investigation

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions