stx typecheck finds script blocks by scanning for the literal tag text without skipping HTML comments. A comment that mentions <script client> in prose opens a block, and everything from there to the next </script> — the remaining prose, the -->, and the real script that follows — is handed to TypeScript.
In a real app this produced 106 errors in one file, every one of them pointing at an English sentence.
Repro
repro.stx, 7 lines:
<!--
This block is deliberately NOT <script client>.
It executes once per full page load and never re-runs.
-->
<script>
const ok = 1
</script>$ stx typecheck "repro.stx"
repro.stx:3:29 error TS1434 Unexpected keyword or identifier. [<script client>]
repro.stx:3:34 error TS1434 Unexpected keyword or identifier. [<script client>]
repro.stx:3:39 error TS1434 Unexpected keyword or identifier. [<script client>]
repro.stx:3:43 error TS1434 Unexpected keyword or identifier. [<script client>]
repro.stx:4:1 error TS1003 Identifier expected. [<script client>]
repro.stx:4:3 error TS1109 Expression expected. [<script client>]
repro.stx:6:3 error TS1109 Expression expected. [<script client>]
Checked 1 script block(s) and 0 template expression(s) in 1 file(s) — 13 error(s), 0 warning(s)Line 3 is prose. Line 4 is -->.
Control
Byte-identical except the comment says a client script instead of <script client>:
Checked 0 script block(s) and 0 template expression(s) in 0 file(s) — 0 error(s), 0 warning(s)So the literal tag text inside the comment is the whole trigger.
Two tells that make this easy to confirm
- The diagnostics are labelled
[<script client>], but the only real script in the file is a plain<script>. The label is coming from the comment. - The reported block count is 1 for a file whose sole genuine block is unparseable-as-client.
Why it bites
Documenting why a block is deliberately not a client script is the natural thing to write directly above it, and writing the tag name is the natural way to say it. The comment that explains the decision is what breaks the check.
The failure is also silent-ish in the wrong direction: it does not crash, it emits a large pile of plausible-looking TS parse errors. First reaction is to go looking for broken code that isn't there. 106 errors from one comment is enough noise to get stx typecheck switched off, which is the same outcome as not shipping it.
Related
Same class as #1831 — scanning source text for a marker without excluding comments — in a different code path. #1831 was the server→client bridge; this is script-block detection in typecheck. Worth a look at whether anything else locates blocks the same way.
Suggested fix
Strip <!-- … --> ranges before locating script blocks, or track comment state while scanning so a marker inside one is skipped.