microsoft / microsoft/vscode-html-languageservice

Allow writing TypeScript in Script tags with @ts-check

Open
#156 3 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
284
Forks
138
Avg merge
19h 11m
Merged PRs (30d)
5

Description

Be able to write TypeScript in Script Tags inside .html files. (I'm not asking for compilation support for .html files only allow the usage and check of TS inside .html files Script Tag)

When we do this: we get the error Type annotations can only be used in TypeScript files. when hovering over the Type.

<script>
  let foo: number = 0;
  foo = "hello";
</script>

//@ts-check works and gives me checks and squiggly lines but still gets not rid of the error above.
A Solution would be if this would work.

<script>
 //@ts-check 
  import { mod } from "./this/should/give/autocomplete"
  let foo: number = 0;
  foo = "hello";

  mod();
</script>

The ideal would be if //@ts-check allows the use of TypeScript inside Script Tags.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files or tests. Start by tracing how the HTML language service handles script tags and the //@ts-check directive; done means TypeScript annotations, type diagnostics, imports, and autocomplete work inside HTML script tags without adding HTML compilation support.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.