Skip to content

can't use typescript's ! in svelte component (outside script) #7754

@Alexandre-Fernandez

Description

@Alexandre-Fernandez

Describe the bug

Svelte doesn't understand ! when it's used outside the script tags.

Reproduction

<script lang="ts">
	let foo: string | undefined = undefined

	function someFunction(param: string) {
		return param
	}

	$: bar = foo
</script>

{#if bar}
	{someFunction(foo!)}
	Unexpected tokensvelte(parse-error)
	Unexpected tokents(-1)
{/if}

Logs

No response

System Info

linux + vscode

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions