Wildcard generation can return empty schemas on Windows due to path comparison

Open Beginner friendly
#638 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
typescript
Domain
tooling

Research direction

Start at buildGenerator(), where onlyIncludeFiles is compared with file.fileName, and review the related pathEqual() use in getMainFileSymbols(). Add a regression test covering Windows-style and slash-separated paths, then run the existing suite. Done means wildcard generation includes the expected definitions on Windows without changing the checked-in schema output.

Written by the indexing model from the issue text.

Description

Summary

On Windows, wildcard generation ("*") can produce an empty definitions object even though named-type generation works.

This was isolated while investigating:
https://github.com/modelcontextprotocol/modelcontextprotocol/issues/3114

Root cause

For the same source file on Windows:

glob result:       schema\draft\schema.ts
TypeScript source: schema/draft/schema.ts

exactStringEqual: false
pathEqual:         true

buildGenerator() currently checks membership using:

return onlyIncludeFiles.indexOf(file.fileName) >= 0;

That causes the source not to be classified as a user file when Windows path separators differ.

Direct instrumentation showed:

rawUserSymbols: 0
rawMainFileSymbols: 0
canonicalUserSymbols: 155
canonicalMainFileSymbols: 155
namedAudioContent: 1

The library already uses pathEqual() for a related comparison in getMainFileSymbols().

Verified fix

Changing:

return onlyIncludeFiles.indexOf(file.fileName) >= 0;

to:

return onlyIncludeFiles.some((f) => pathEqual(f, file.fileName));

was tested against the Model Context Protocol schema generator on Windows with typescript-json-schema 0.68.0.

Generated definition counts after the fix:

2024-11-05     79
2025-03-26     83
2025-06-18     91
2025-11-25    145
2026-07-28    155
draft         155

The regenerated schemas had no diff from the checked-in files.

Validation result:

Results: 258 passed, 0 failed

I can submit a focused PR with the one-line fix and a regression test.

Dominant language
TypeScript
Stars
3.3k
Forks
332
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from YousefED/typescript-json-schema

All issues in YousefED/typescript-json-schema

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.