fix(types): export the generated Data union instead of a deleted module - #8002
Closed
jcampbell wants to merge 1 commit into
Closed
fix(types): export the generated Data union instead of a deleted module#8002jcampbell wants to merge 1 commit into
Data union instead of a deleted module#8002jcampbell wants to merge 1 commit into
Conversation
…dule `lib/index.d.ts` re-exported `Data` from `src/types/core/data`, which was removed in 1f1898e ("refactor: Generate data type union instead of hand writing"). That commit repointed the five importers under `src/types/`, but `lib/index.d.ts` and `src/types/core/data.internal.d.ts` were missed. The entry point already re-exports the generated schema with `export type *`, and the generator now emits `Data` there. An explicit named re-export takes precedence over a star re-export, so the dangling line shadowed the working union and `Data` resolved to `any` for every consumer. `skipLibCheck: true` — the default in most app tsconfigs — hides the unresolved module, so the failure is silent: traces annotated `Data` are simply unchecked. Reproduced against plotly.js 4.0.0 from npm: import type { Data } from 'plotly.js'; declare const d: Data; const n: number = d; // no error const s = d.nonexistentProperty; // no error Both now error as expected, and `FullData` resolves with `skipLibCheck: false`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
|
Thanks for the PR! This is actually being fixed in #8000, so I'm going to close this one. But I missed the docstring update, so I'll add that to mine. Good catch! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
lib/index.d.tsre-exportsDatafromsrc/types/core/data:That file was removed in 1f1898e ("refactor: Generate data type union instead of hand writing"), which moved the union into
src/types/generated/schema.d.ts. The commit repointed the five importers undersrc/types/, but missedlib/index.d.tsandsrc/types/core/data.internal.d.ts.The entry point already does
export type * from '../src/types/generated/schema', which supplies the generatedData. But an explicit named re-export takes precedence over a star re-export, so the dangling line shadows the working union — and because the module it names doesn't exist,Dataresolves toanyfor every consumer.This is silent in practice.
skipLibCheck: trueis the default in most application tsconfigs (and intsc --init), which suppresses the unresolved-module error inside the declaration file. The result is that traces annotatedData— the primary public type of the library — are simply unchecked, with nothing to indicate it.Reproduction
Against
plotly.js@4.0.0from npm, withstrict: trueandskipLibCheck: true:LayoutandConfigbehave correctly, which is what makes theDatacase easy to miss.Fix
lib/index.d.ts; the star re-export of the generated schema already exportsData.src/types/core/data.internal.d.tsat../generated/schema(it importsDatato buildFullData), and update the stale doc comment pointing atdata.d.ts.Verification
Both lines above now error as expected. With
skipLibCheck: false,DataandFullDataboth resolve and no dangling-module errors remain.Found while migrating an app from
@types/plotly.jsto the declarations plotly.js 4 now ships. The migration typechecked clean because of this bug; onceDataresolved, it caught three real defects in our own code.🤖 Generated with Claude Code