Skip to content

[vue-component-meta] When the props name starts with 'on', it is not included in the generated meta props #5166

Open
@Zephyrrro

Description

Vue - Official extension or vue-tsc version

2.2.0

VSCode version

1.96.4 (Universal)

Vue version

3.3.8

TypeScript version

5.0.2

System Info

System:
    OS: macOS 13.4
    CPU: (10) arm64 Apple M1 Pro
    Memory: 232.38 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
    Yarn: 1.22.21 - ~/Library/pnpm/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
    pnpm: 7.18.2 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 132.0.6834.160
    Safari: 16.5

package.json dependencies

{
  "devDependencies": {
    "@vue/language-plugin-pug": "2.2.0",
    "vue": "3.3.8",
    "vue-component-meta": "2.2.0",
    "typescript": "5.0.2"
  }
}

Steps to reproduce

  1. create a SFC with the below contents.
<template lang="pug">
div
</template>

<script lang="ts" setup>
defineProps<{
  onFoo: () => void;
  bar: () => void;
}>();
</script>
  1. then use vue-component-meta to extract the meta-data.
import { createChecker } from 'vue-component-meta';

const componentPath = path.resolve(__dirname, '../src/test.vue');

const checker = createChecker(
  path.resolve(__dirname, '../tsconfig.json'),
  {
    forceUseTs: true,
    printer: { newLine: 1 },
    noDeclarations: true,
  },
);

const meta = checker.getComponentMeta(componentPath);
console.log(meta)

What is expected?

there is an item in meta-data's props like this

  {
    "name": "onFoo",
    "global": false,
    "description": "",
    "tags": [],
    "required": true,
    "type": "() => void",
    "declarations": [],
    "schema": {
      "kind": "event",
      "type": "(): void"
    }
}

What is actually happening?

Can not find onFoo in the generated meta-data's props

{
  "type": 1,
  "props": [
    {
      "name": "bar",
      "global": false,
      "description": "",
      "tags": [],
      "required": true,
      "type": "() => void",
      "declarations": [],
      "schema": {
        "kind": "event",
        "type": "(): void"
      }
    },
    // ... global props
  ],
  "events": [],
  "slots": [],
  "exposed": [
    {
      "name": "onFoo",
      "type": "() => void",
      "description": "",
      "declarations": [],
      "schema": {
        "kind": "event",
        "type": "(): void"
      }
    },
    {
      "name": "bar",
      "type": "() => void",
      "description": "",
      "declarations": [],
      "schema": {
        "kind": "event",
        "type": "(): void"
      }
    }
  ]
}

Link to minimal reproduction

No response

Any additional comments?

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions