Skip to content

Missing type in Svelte compiler AST #14246

@Ice-mourne

Description

@Ice-mourne

Describe the bug

The script part of AST specifically imports are missing importKind type

Reproduction

import { parse } from 'svelte/compiler';

const ast = parse(`
<script lang="ts">
  import type { Snippet } from 'svelte'
  import { mount } from 'svelte'
</script>
`, { modern: true })

// narrow down type to import declarations
if (ast.instance?.content.body[0].type === 'ImportDeclaration') {
  // this gives error // Property 'importKind' does not exist on type 'ImportDeclaration'.
  ast.instance?.content.body[0].importKind
  
  // But if we log it we can see it dose have them
  console.log(ast.instance?.content.body[0].importKind) // type
  console.log(ast.instance?.content.body[1].importKind) // value
}

Logs

No response

System Info

Not important

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions