Published declarations import types from connect, @babel/core and @babel/traverse, whose @types packages are not dependencies

未关闭
#2,135 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
领域
tooling

调研方向

Start with the declaration imports in packages/metro-config/src/types.js and packages/metro/src/Server.js, then inspect the package manifests for metro-config and metro and the other declaration files named in the report. Reproduce the failure with the linked project’s npm run typecheck using skipLibCheck: false; done means the published packages type-check without the missing-declaration errors.

由索引模型根据 Issue 内容生成。

描述

Reproduction: https://github.com/YevheniiKotyrlo/metro-connect-types

A TypeScript project that depends on metro-config and type-checks it with skipLibCheck: false fails on metro's own declarations: they import types from connect, @babel/core and @babel/traverse, and no metro package depends on @types/connect, @types/babel__core or @types/babel__traverse. metro-config lists @types/connect under devDependencies only, and metro not at all.

Steps (metro 0.87.2, metro-config 0.87.2, TypeScript 6.0.3, npm 12, Node 26, Windows 11 and Ubuntu 22.04 under WSL):

  1. npm install
  2. npm run typecheck, which runs tsc -p . over an index.ts holding import type { ConfigT } from 'metro-config';, with strict, "skipLibCheck": false and "types": ["node"].

Expected: no error.

Seen:

node_modules/metro-babel-transformer/src/index.d.ts(18,38): error TS7016: Could not find a declaration file for module '@babel/core'. 'node_modules/@babel/core/lib/index.js' implicitly has an 'any' type.
node_modules/metro-babel-transformer/src/index.d.ts(21,36): error TS7016: Could not find a declaration file for module '@babel/core'. 'node_modules/@babel/core/lib/index.js' implicitly has an 'any' type.
node_modules/metro-config/src/types.d.ts(18,43): error TS7016: Could not find a declaration file for module 'connect'. 'node_modules/connect/index.js' implicitly has an 'any' type.
node_modules/metro-source-map/src/generateFunctionMap.d.ts(19,30): error TS7016: Could not find a declaration file for module '@babel/core'. 'node_modules/@babel/core/lib/index.js' implicitly has an 'any' type.
node_modules/metro/src/ModuleGraph/worker/collectDependencies.d.ts(18,29): error TS7016: Could not find a declaration file for module '@babel/traverse'. 'node_modules/@babel/traverse/lib/index.js' implicitly has an 'any' type.
node_modules/metro/src/Server.d.ts(26,36): error TS7016: Could not find a declaration file for module 'connect'. 'node_modules/connect/index.js' implicitly has an 'any' type.

On main (a87d864565ae34826ab2425a1f06341c16a2c515) the same holds: I ran yarn build-ts-defs and node scripts/build.js under Ubuntu, packed metro-config and metro after prepare-release, installed both packs in the same project and ran the same check, which prints the same six errors. packages/metro-config/src/types.js imports HandleFunction and Server from connect, and packages/metro/src/Server.js imports IncomingMessage from it.

An app that happens to install those @types packages, as many React Native apps do through other dependencies, never sees this; a project that depends on metro alone does.

主要语言
JavaScript
星标
5.7k
派生
711
平均合并
2 天 18 小时
30 天内合并 PR
66

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

react/metro 的其他 Issue

查看 react/metro 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。