@dbml/[email protected]+ ships incomplete TypeScript declarations

Aperta Adatta ai principianti
#1,048 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

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

Direzione di ricerca

Inizia esaminando le dichiarazioni del pacchetto pubblicato in types/model_structure/element.d.ts e la configurazione di compilazione o packaging TypeScript del pacchetto; l’issue non indica i percorsi del repository dei file sorgente. Confronta le dichiarazioni nelle release interessate con 11.0.1, quindi esegui la riproduzione TypeScript fornita con un pacchetto impacchettato. Il lavoro è concluso quando il pacchetto include dichiarazioni risolvibili e TypeScript accetta schema.id, table.token, field.id e field.token.

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

Descrizione

Hi DBML team,

Starting with @dbml/[email protected], the published TypeScript declarations reference an Element module that is missing from the npm tarball. As a result, TypeScript rejects access to token and id properties that are present on models returned by Parser.parse().

Tested versions

I tested clean installs from the npm registry with TypeScript 6.0.3 and matching @dbml/core and @dbml/parse versions.

@dbml/core Result
10.1.1, 11.0.0, 11.0.1 The reproduction compiles
11.1.0, 12.0.0, 12.1.0 The reproduction fails with the same four TS2339 errors
Steps to reproduce

In a fresh directory, install the published package.

npm init -y
npm install --save-exact @dbml/[email protected]
npm install --save-dev --save-exact [email protected]

Save this as repro.mts.

import { Parser } from '@dbml/core';

const schema = Parser.parse('Table t { id int }', 'dbmlv2').schemas[0];
const table = schema.tables[0];
const field = table.fields[0];

console.log(schema.id);
console.log(table.token.start.offset);
console.log(field.id);
console.log(field.token.start.offset);
npx tsc --noEmit --strict --skipLibCheck --target es2022 \
  --module esnext --moduleResolution bundler repro.mts
Expected behavior

The declarations shipped in the npm package resolve to files in the package. TypeScript recognizes schema.id, table.token, field.id, and field.token.

Actual behavior
repro.mts(7,20): error TS2339: Property 'id' does not exist on type 'Schema'.
repro.mts(8,19): error TS2339: Property 'token' does not exist on type 'Table'.
repro.mts(9,19): error TS2339: Property 'id' does not exist on type 'Field'.
repro.mts(10,19): error TS2339: Property 'token' does not exist on type 'Field'.

Running the same file with node repro.mts on Node.js 26.13.1 succeeds and prints 1, 0, 1, and 10 on separate lines.

What is in the published tarball

In each affected tarball, types/model_structure/element.d.ts imports Element and re-exports Color, Token, and RawNote from ../../src/model_structure/element. The tarballs contain the compiled JavaScript under lib/model_structure/, but omit src/model_structure/element.ts and any declaration at that path. The 11.0.1 tarball declares these types directly in element.d.ts. [11.0.1 tarball](https://registry.npmjs.org/@dbml/core/-/core-11.0.1.tgz), [11.1.0 tarball](https://registry.npmjs.org/@dbml/core/-/core-11.1.0.tgz), [12.0.0 tarball](https://registry.npmjs.org/@dbml/core/-/core-12.0.0.tgz), [12.1.0 tarball](https://registry.npmjs.org/@dbml/core/-/core-12.1.0.tgz)

Removing --skipLibCheck also surfaces the unresolved reference directly. The following two lines are from the compiler output.

node_modules/@dbml/core/types/model_structure/element.d.ts(1,44): error TS2307: Cannot find module '../../src/model_structure/element' or its corresponding type declarations.
node_modules/@dbml/core/types/model_structure/element.d.ts(2,21): error TS2307: Cannot find module '../../src/model_structure/element' or its corresponding type declarations.
Suggested fix

Could the package ship a self-contained declaration for Element, or point element.d.ts to a declaration that is included in the npm tarball? Schema and Field also need declarations for their runtime id properties. In a local check, supplying the Element declaration restored the token properties, and the two id errors remained until those properties were declared on Schema and Field.

Thanks!

Lingua principale
JavaScript
Stelle
3.7k
Fork
233
Merge medio
2g 4h
PR unite (30g)
23

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 holistics/dbml

Tutte le issue di holistics/dbml

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.