Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patterns with fields with privacy policies generate invalid JS #1864

Open
Swahvay opened this issue Dec 16, 2024 · 1 comment
Open

Patterns with fields with privacy policies generate invalid JS #1864

Swahvay opened this issue Dec 16, 2024 · 1 comment

Comments

@Swahvay
Copy link
Contributor

Swahvay commented Dec 16, 2024

If a pattern has a struct field with a privacy policy, the type that is specified in the return of the check function is missing in the import list. I.e.:

export const SomePattern: Pattern = {
  name: 'SomePattern',
  fields: {
    someEnumField: StructTypeAsList({
      tsType: 'SomeEnumField',
      nullable: true,
      privacyPolicy: {
        rules: [AlwaysDenyRule],
      },
      fields: {
        a: BooleanType(),
        b: StringType(),
      },
    }),
  },
};

Generates the following in each base class:

async someEnumFields(): Promise<SomeEnumField[] | null> {
  if (this._someEnumField === null) {
    return null;
  }
  // etc.
}

But SomeEnumField is never imported so we get TS build errors.

@Swahvay
Copy link
Contributor Author

Swahvay commented Dec 17, 2024

The offending line: base.tmpl#L186. Unfortunately I don't know enough about Go templating to know how to import that file appropriately.

@Swahvay Swahvay changed the title Patterns with struct fields with privacy policies generate invalid JS Patterns with fields with privacy policies generate invalid JS Dec 17, 2024
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

No branches or pull requests

1 participant