Skip to content

[BUG]: better handling of multiple @generateTypes() calls #179

@theoephraim

Description

@theoephraim

varlock version

0.0.15

Steps to reproduce

Import multiple .env.schema files which contain @generateTypes calls.

What is expected?

Only the primary file will have its types generated, including imported items. Type generation in the imported services will be skipped.

What is actually happening?

Each service has its types generated, but includes all items.

Any additional comments?

Currently the behaviour is that type generation is skipped if the file is imported partially (meaning specific keys are imported). The intention here is that you might just be breaking up a large schema, so we dont necessarily know in what cases you wanted to skip type generation in an imported file in all cases.

One possible solution is trying to infer if the file is the main schema, or doing some special handling of files named .env.schema.

I believe a better solution is to let the user trigger this partial import treatment, even when importing all items. You're letting the user say - "import this file fully as if it was part of this one" versus "import all items from this other file".

This could be implemented by adding wildcards to the import list. For example

  • @import(../other-file) - imports fully, a contained @generateTypes call would be executed
  • @import(../other-file, *) - imports partially, all items included, but a contained @generateTypes call is skipped

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions