Skip to content

Unable to infer map callback argument inside Vue template #5570

@IlyaSemenov

Description

@IlyaSemenov

Vue - Official extension or vue-tsc version

3.0.4

VSCode version

Vue version

3.5.18

TypeScript version

5.8.3

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm

package.json dependencies

{
  "devDependencies": {
    "nuxt": "^3.18.0",
    "typescript": "^5.8.3",
    "vue-tsc": "^3.0.4"
  }
}

Steps to reproduce

  1. Open https://stackblitz.com/edit/nuxt-starter-vhasy428
  2. Press ^C and run: pnpm vue-tsc --noEmit

The file is as simple as:

<script lang="ts" setup>
import type { Component } from 'vue';

const cc: Component[] = [];
</script>

<template>
  <pre>{{ cc.map((c) => c.name) }}</pre>
</template>

What is expected?

No type errors.

What is actually happening?

❯ pnpm vue-tsc --noEmit
app.vue:8:19 - error TS7006: Parameter 'c' implicitly has an 'any' type.

8   <pre>{{ cc.map((c) => c.name) }}</pre>
                    ~


Found 1 error in app.vue:8

Link to minimal reproduction

https://stackblitz.com/edit/nuxt-starter-vhasy428

Any additional comments?

This is happening with any externally imported type. I chose Component for simplicity, it's just some type from an already installed package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good reproduction ✨This issue provides a good reproduction, we will be able to investigate it firstquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions