Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow writing TypeScript in Script tags with @ts-check #156

Open
ivanjeremic opened this issue Mar 28, 2023 · 3 comments
Open

Allow writing TypeScript in Script tags with @ts-check #156

ivanjeremic opened this issue Mar 28, 2023 · 3 comments

Comments

@ivanjeremic
Copy link

ivanjeremic commented Mar 28, 2023

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.

@Heath123
Copy link

I’d like this too, with a way to specify a tsconfig.json

@Heath123
Copy link

If you go to this function
https://github.com/microsoft/vscode/blob/ce00cd7812aa1c8fa63cf5630f28fd3f9197fdc6/extensions/html-language-features/server/src/modes/javascriptMode.ts#L29-L34
and add
return ts.ScriptKind.TS;
at the start of the function then it works but it also causes errors because it checks things you might not want checked as well

@qrhfz
Copy link

qrhfz commented Nov 27, 2023

usually //@ts-check is used with jsdoc for type annotation instead of typescript syntax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants