Skip to content

Comments

feat(compiler): Add interface typekit ($.interface)#9771

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-interface-typekit
Draft

feat(compiler): Add interface typekit ($.interface)#9771
Copilot wants to merge 2 commits intomainfrom
copilot/add-interface-typekit

Conversation

Copy link
Contributor

Copilot AI commented Feb 23, 2026

Interfaces were the only major TypeSpec type without a corresponding typekit entry. This adds $.interface with create and is methods, consistent with existing kits for model, operation, enum, etc.

Changes

  • kits/interface.ts — New InterfaceKit with:
    • create(desc: InterfaceDescriptor): Interface — builds a finished Interface type, optionally with pre-built operations
    • is(type: Entity): type is Interface — type guard
  • kits/index.ts / typekit/index.ts — Export InterfaceKit and InterfaceDescriptor
  • test/typekit/interface.test.ts — Tests for is, create (empty), and create with operations

Usage

const op = $(program).operation.create({
  name: "list",
  parameters: [],
  returnType: $(program).intrinsic.void,
});

const iface = $(program).interface.create({
  name: "PetService",
  operations: [op],
});

$(program).interface.is(iface); // true
iface.operations.get("list");   // op, with op.interface === iface
Original prompt

This section details on the original issue you should resolve

<issue_title>[compiler] There is no typekit for interfaces</issue_title>
<issue_description>### Clear and concise description of the problem

This seems like an oversight. We have typekits for everything else, but none for making an interface.

Checklist

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.</issue_description>

<agent_instructions>Follow the examples of other typekits in packages/compiler/src/typekit/kits to create a versatile typekit for creating instances of interfaces.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: witemple-msft <77019085+witemple-msft@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service bot added the compiler:core Issues for @typespec/compiler label Feb 23, 2026
Copilot AI changed the title [WIP] Add typekit for creating interfaces feat(compiler): Add interface typekit ($.interface) Feb 23, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 23, 2026

Open in StackBlitz

npm i https://pkg.pr.new/microsoft/typespec/@typespec/compiler@9771

commit: 7903666

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

Labels

compiler:core Issues for @typespec/compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[compiler] There is no typekit for interfaces

2 participants