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

Aperta
#2,135 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, node.js, typescript
Ambito
tooling

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
JavaScript
Stelle
5.7k
Fork
711
Merge medio
2g 18h
PR unite (30g)
66

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di react/metro

Tutte le issue di react/metro

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.