VS Code displays an error on type annotation
See original GitHub issueI have the Svelte Beta extension installed and have restarted the language server. My svelte.config.js
is:
const sveltePreprocess = require('svelte-preprocess');
module.exports = {
preprocess: sveltePreprocess(),
};
However, the extension does not seem to help VS Code understand that my code is Typescript, since it gives an error on type annotation:
Type annotations can only be used in TypeScript files. javascript
Also interesting, if I change lang="typescript"
to type="text/typescript"
, the syntax colours completely go away, as well as the error:
System (please complete the following information):
- OS: macOS Catalina 10.15.4
- IDE: VS Code
- Plugin: Svelte Beta
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Syntax highlighting not working for Python in VS Code with ...
I'm trying to get Visual Studio Code to format (the colours not the layout) Python code with type annotations (hinting).
Read more >TypeScript editing with Visual Studio Code
VS Code's TypeScript IntelliSense understands many standard JSDoc annotations, and uses them to show typing information and documentation in suggestions, hover ...
Read more >TypeScript Programming with Visual Studio Code
You'll notice the TypeScript keyword let and the string type declaration. ... Ctrl+Shift+M to display the PROBLEMS panel with a list of all...
Read more >Working with JavaScript in Visual Studio Code
VS Code allows you to leverage some of TypeScript's advanced type checking and error reporting functionality in regular JavaScript files. This is a...
Read more >Syntax Highlight Guide | Visual Studio Code Extension API
Syntax highlighting determines the color and style of source code displayed in the Visual Studio Code editor. It is responsible for colorizing keywords...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ah, so the problem was because I had this in my VS Code “User” settings:
Now that I’ve removed it, everything seems to work fine.
Not sure if this is related but I’m getting the same error on a
number
annotation using Neovim:tsconfig:
EDIT: Nevermind, I was missing
lang="ts"
on the script tag. Should have been<script lang="ts">