Skip to content

Fix @generateTypes producing empty output when schema file has env-like name#550

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-generate-types-custom-path
Draft

Fix @generateTypes producing empty output when schema file has env-like name#550
Copilot wants to merge 2 commits intomainfrom
copilot/fix-generate-types-custom-path

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 3, 2026

When using varlock typegen --path .env.infra.schema, the generated type file contained no variables despite the schema having items defined.

Root cause

FileBasedDataSource parses .env.infra.schema as: schema → recognized type suffix (popped), leaving ['env', 'infra']applyForEnv = 'infra'. Since the file is not an import (isImport = false), isEnvSpecific returned true, causing all items to be filtered out of defsForTypeGeneration.

The key issue: the applyForEnv env-specificity check didn't distinguish between files auto-loaded by a DirectoryDataSource (which have a parent) and an explicitly-provided root entry file (which has no parent).

Fix

  • data-source.ts — Add && this.parent to the applyForEnv check in isEnvSpecific. Root entry files (set via setRootDataSource) never have a parent assigned, so they're no longer incorrectly treated as env-specific. Auto-loaded files like .env.production always have a parent (DirectoryDataSource), so existing behavior is preserved.

  • type-generation.test.ts — Regression test: loading .env.infra.schema as the root entry via setRootDataSource now correctly produces a non-env-specific source with items present in defsForTypeGeneration.

// Before: applyForEnv='infra' + isImport=false → isEnvSpecific=true → empty types
// After:  applyForEnv='infra' + isImport=false + parent=undefined → isEnvSpecific=false → variables included
get isEnvSpecific(): boolean {
  if (this.applyForEnv && !this.isImport && this.parent) return true; // parent check added
  ...
}

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 3, 2026

🦋 Changeset detected

Latest commit: 5b200d8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 18 packages
Name Type
varlock Patch
@varlock/astro-integration Patch
@varlock/cloudflare-integration Patch
@varlock/expo-integration Patch
@varlock/nextjs-integration Patch
@varlock/vite-integration Patch
@varlock/1password-plugin Patch
@varlock/aws-secrets-plugin Patch
@varlock/azure-key-vault-plugin Patch
@varlock/bitwarden-plugin Patch
@varlock/dashlane-plugin Patch
@varlock/google-secret-manager-plugin Patch
@varlock/hashicorp-vault-plugin Patch
@varlock/infisical-plugin Patch
@varlock/keepass-plugin Patch
@varlock/pass-plugin Patch
@varlock/passbolt-plugin Patch
@varlock/proton-pass-plugin Patch

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 @generateTypes producing empty output when schema file has env-like name Apr 3, 2026
Copilot AI requested a review from philmillman April 3, 2026 19:03
@philmillman philmillman requested a review from theoephraim April 3, 2026 19:09
@philmillman
Copy link
Copy Markdown
Member

@theoephraim not sure the implications here, especially with "env-like" single filenames

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: @generateTypes doesn't create variables when using custom path with varlock typegen

2 participants