Skip to content

Variables created with Pug/Svelte mixin +each are not recognized by Typescript #207

Open
@braindefender

Description

@braindefender

Problem

Variables created with Pug/Svelte mixin (i.e. +each('links as link')) are not recognized by Typescript analyzer
and cause "Cannot find name 'link'. Did you mean 'links'?" error.

Imgur

Example code:

<template lang="pug">
ul.nav
  +each('links as link')
    li(class:active="{ link.active }")
      a(href!="{ link.link }") { link.title }
</template>

<script lang="ts">
interface Link {
  active: boolean 
  link: string
  title: string
}

let links: Link[] = [
  { active: false, link: '#', title: 'Test Link 1' }, 
  { active: false, link: '#', title: 'Test Link 2' }, 
  { active: false, link: '#', title: 'Test Link 3' }, 
]
</script>

Context

Editor: VS Code or NVim
Used preprocessors: Typescript, Pug, Sass.
svelte-preprocess version: 4.0.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions