antfu / nuxt-content-twoslash

TwoSlash integrations for Nuxt Content
MIT License
41 stars 4 forks source link

Throw an error when using `document`. #2

Open gjssss opened 4 months ago

gjssss commented 4 months ago

Describe the bug

In nuxt.config.ts I have added compilerOptions

twoslash: {
  compilerOptions: {
    lib: ['ES5', 'ES6', 'ESNext', 'DOM'],
    target: ScriptTarget.ES2016,
  },
},

But when I use document in my code, it still throw an error

--------
Twoslash error in code:
--------
const app = document.getElementById('#app')
--------

TwoslashError: 
## Errors were thrown in the sample, but not included in an error tag

These errors were not marked as being expected: 2584.
Expected: // @errors: 2584

Compiler Errors:

index.ts
  [2584] 12 - Cannot find name 'document'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'.

The markdown file is in content/blog/test.md

Reproduction

https://github.com/gjssss/hellogjs.top/tree/cddae922b9cd3a68154e76d86c339914a901d83c

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (16) x64 AMD Ryzen 7 6800H with Radeon Graphics
    Memory: 4.16 GB / 13.69 GB
  Binaries:
    Node: 20.11.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.15.0 - C:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Edge: Chromium (122.0.2365.66)
    Internet Explorer: 11.0.22621.1

Used Package Manager

pnpm

Validations