I am currently working with Svelte (Vite) + Bootstrap 5 + SvelteStrap. The code I have written is as follows:
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9bf9f4f4efe8efe9faebdbaeb5aab5ab">[email protected]</a>/dist/css/bootstrap.min.css">
</head>
<script>
import { Button } from 'sveltestrap';
let color = "danger";
</script>
<div>
<Button color="{color}">{color}</Button>
</div>
While this code works fine in the browser, I am encountering an error in VSCode:
Type 'string' is not assignable to type 'ButtonColor'.
I am new to Svelte and I am attempting to modify the default example on the SvelteStrap website:
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="25474a4a51565157445565100b140b">[email protected]</a>/dist/css/bootstrap.min.css">
</head>
<script lang="ts">
import { Button } from 'sveltestrap';
const colors: any = [
'primary',
'secondary',
'success',
'danger',
'warning',
'info',
'light',
'dark'
];
</script>
{#each colors as color}
<div>
<Button {color}>{color}</Button>
</div>
{/each}
When I use the default example, I do not encounter any errors. What could be the reason for this discrepancy? What am I missing?