Skip to content

[Bug]: Quirks while deriving models #11720

Description

Describe the bug

I can not find the right strategy to work with visibility filters.
Below are some examples.

Please explain how to cope with.

TIA

Reproduction

Example 1:

using Reflection;

model Foo {
  id: string,
  parent_id: Foo.id,
  parent: Foo,
}

// NB: FilterVisibility _does require_ the name argument
alias GuessReadType<Type extends Model> = FilterVisibility<Type, #{ all: #[Lifecycle.Read] }, "{name}Read">;

// Duplicate type name: 'FooRead'
model FooRead is GuessReadType<Foo> {}

Example 2:

using Reflection;

// Duplicate type name: 'Foo'
model Foo {
  id: string,
  parent_id: Foo.id,
  parent: Foo,
}

// NB: FilterVisibility _does require_ the name argument
alias GuessReadType<Type extends Model> = FilterVisibility<Type, #{ all: #[Lifecycle.Read] }, "">;

model FooRead is GuessReadType<Foo> {}

Checklist

Metadata

Metadata

Labels

bugSomething isn't workingcompiler:coreIssues for @typespec/compiler

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions