[Bug]: 0.5.1 主入口声明在 Vue/Vite 项目中关闭 skipLibCheck 后类型检查失败
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 74/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- typescript, vite
- 領域
- build-system, testing
調査の方向性
Start with the reported errors in dist/index.d.ts and trace them back through the declaration-generation and packaging configuration. Reproduce with the provided package.json and tsconfig.json, then run pnpm typecheck; done means the published main entry type-checks with skipLibCheck: false and a consumer test imports Vue components from that entry point.
索引モデルが issue の本文から書いたものです。
説明
问题描述
在 Vue 3 + Vite 的 TypeScript 项目中,从 @opentiny/[email protected] 主入口导入组件,关闭 skipLibCheck 后,vue-tsc 会在包内 dist/index.d.ts 报错。
使用的是常规 module: "ESNext"、moduleResolution: "bundler" 配置,不涉及 NodeNext。以下示例消费 npm 已发布的 0.5.1,不依赖源码仓库或未发布的 PR 构建。
最小复现
创建以下文件:
package.json
{
"name": "tiny-robot-types-repro",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"typecheck": "vue-tsc --noEmit",
"typecheck:skip": "vue-tsc --noEmit --skipLibCheck"
},
"dependencies": {
"@opentiny/tiny-robot": "0.5.1",
"vue": "3.5.44",
"dompurify": "3.4.17",
"markdown-it": "14.3.3"
},
"devDependencies": {
"@vitejs/plugin-vue": "4.6.2",
"vite": "5.4.21",
"typescript": "5.8.3",
"vue-tsc": "3.3.13"
}
}
tsconfig.json
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"lib": [
"ES2022",
"DOM",
"DOM.Iterable"
],
"strict": true,
"skipLibCheck": false,
"noEmit": true,
"types": []
},
"include": [
"src/**/*.ts",
"src/**/*.vue"
]
}
vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig({ plugins: [vue()] })
index.html
<!doctype html>
<html>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
src/main.ts
import { createApp } from 'vue'
import App from './App.vue'
createApp(App).mount('#app')
src/App.vue
<script setup lang="ts">
import { TrAnchor, type AnchorItem } from '@opentiny/tiny-robot'
const items: AnchorItem[] = [{ id: 'intro', label: '简介' }]
</script>
<template>
<TrAnchor :items="items" />
</template>
在该目录执行:
pnpm install
pnpm typecheck
实际结果
类型检查退出码为 2。主入口声明中的代表性错误如下(路径简写为包内相对路径):
dist/index.d.ts(161,83): error TS2300: Duplicate identifier 'event'.
dist/index.d.ts(197,20): error TS2344: Type 'GlobalComponents' does not satisfy the constraint 'Record<string, Component<...>>'.
dist/index.d.ts(215,12): error TS2749: 'nextTick' refers to a value, but is being used as a type here. Did you mean 'typeof nextTick'?
dist/index.d.ts(5497,44): error TS2304: Cannot find name 'MentionAttrs'.
dist/index.d.ts(5522,45): error TS2304: Cannot find name 'TemplateAttrs'.
dist/index.d.ts(5530,51): error TS2304: Cannot find name 'TemplateSelectAttrs'.
其中 TS2344 的泛型约束用 ... 省略了冗长参数。依赖链还可能报告其他环境类型错误;这里列出的错误均位于 tiny-robot 自身的主入口声明。
对照执行:
pnpm typecheck:skip
本示例可通过。执行 pnpm dev 也可以启动页面,因为 Vite 本身不执行完整的 TypeScript 类型检查。
预期结果
主入口发布的声明应在支持的 Vue 项目中通过类型检查,无需依赖 skipLibCheck: true 隐藏包内声明错误。
验证版本
- @opentiny/tiny-robot:0.5.1
- Vue:3.5.44
- TypeScript:5.8.3
- vue-tsc:3.3.13
- Vite:5.4.21
- @vitejs/plugin-vue:4.6.2
希望检查声明生成/打包结果,并增加一个从发布产物主入口导入 Vue 组件、关闭 skipLibCheck 的消费者类型检查。
- 主要言語
- TypeScript
- スター
- 109
- フォーク
- 19
- 平均マージ
- 1日 21時間
- マージ済み PR(30日)
- 25
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
opentiny/tiny-robot のほかの issue
-
优化文档的outline展示オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
opentiny/tiny-robot#512 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
opentiny/tiny-robot#403 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
opentiny/tiny-robot#515 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 38/100
opentiny/tiny-robot#474 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 1/100
opentiny/tiny-robot#456 ·
メンテナーはふだん 1 日以内に返信
opentiny/tiny-robot の issue をすべて見る
似ている issue
-
MCP tool results drop structuredContent when text is only a summary対応中かも @Pankaj-bit361 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
inblockio/siwx-oidc-matrix-server#101 ·
メンテナーはふだん 1 日以内に返信
-
status:needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
pingdotgg/t3code#42253 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信