Fix @generateTypes producing empty output when schema file has env-like name#550
Draft
Fix @generateTypes producing empty output when schema file has env-like name#550
@generateTypes producing empty output when schema file has env-like name#550Conversation
🦋 Changeset detectedLatest commit: 5b200d8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 18 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…hema file as --path entry point Agent-Logs-Url: https://github.com/dmno-dev/varlock/sessions/53e5a64d-4a9e-4f24-9054-1c8ce5e1b690 Co-authored-by: philmillman <3722211+philmillman@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix @generateTypes not creating variables with custom path
Fix Apr 3, 2026
@generateTypes producing empty output when schema file has env-like name
Member
|
@theoephraim not sure the implications here, especially with "env-like" single filenames |
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.
When using
varlock typegen --path .env.infra.schema, the generated type file contained no variables despite the schema having items defined.Root cause
FileBasedDataSourceparses.env.infra.schemaas:schema→ recognized type suffix (popped), leaving['env', 'infra']→applyForEnv = 'infra'. Since the file is not an import (isImport = false),isEnvSpecificreturnedtrue, causing all items to be filtered out ofdefsForTypeGeneration.The key issue: the
applyForEnvenv-specificity check didn't distinguish between files auto-loaded by aDirectoryDataSource(which have a parent) and an explicitly-provided root entry file (which has no parent).Fix
data-source.ts— Add&& this.parentto theapplyForEnvcheck inisEnvSpecific. Root entry files (set viasetRootDataSource) never have a parent assigned, so they're no longer incorrectly treated as env-specific. Auto-loaded files like.env.productionalways have a parent (DirectoryDataSource), so existing behavior is preserved.type-generation.test.ts— Regression test: loading.env.infra.schemaas the root entry viasetRootDataSourcenow correctly produces a non-env-specific source with items present indefsForTypeGeneration.