Skip to content

Template expressions don't reflect <script> narrowing #2792

@rebasecase

Description

@rebasecase

Description

<script>
let { data } = $props(); // {myProp?: string}

if (!data.myProp) { throw error(404, "nope");}
</script>

{#if data.myProp === "foo"} // data.myProp is possibly 'undefined'
{/if}

Proposed solution

I'm not sure

Alternatives

!. or non null checks.

Additional Information, eg. Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions