Skip to content

Missing interface in non-modular code generation #3820

@alfie80

Description

@alfie80

Hi Team,

I have below model definitions in Typespec and I found the the interfaces CatDef and DefaultPets will be missed in the generated codes. However, switching to modular mode (setting is-modular-library to true), the interfaces are generated.


model DefaultPets {
    catList?: CatDef[] = #[
        #{
            catType: "American Shorthair"
        }
    ];
}

model PetSettings {
    petList?: {
      cat?: DefaultPets.catList;
    },
}

model CatDef {
  catType: string;
}

The problem seems relates to cat?: DefaultPets.catList in model PetSettings. After changing it to below, the interface CatDef can be generated.

model PetSettings {
    petList?: {
      cat?: CatDef[] = #[
        #{
            catType: "American Shorthair"
         }
      ];
    },
}

Here is my emitter setting in tspconfig.yaml:

emit:
  - '@azure-tools/typespec-ts'
options:
  "@azure-tools/typespec-ts":
    azure-sdk-for-js: false
    enable-operation-group: true
    include-shortcuts: true
    is-modular-library: false
    ignore-property-name-normalize: true

Metadata

Metadata

Labels

RLCcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions