Skip to content

IR.Context is incorrectly typed with recursive any after 0.86 #2904

@shwu-jt

Description

@shwu-jt

Description

This is similar to #2896. Before 0.86, the generated type for IR$1.Context was:

declare namespace IR$1 {
  ...
  export type Context<Spec extends Record<string, any> = any> = IRContext<Spec>;
  ...
}

After 0.86, it becomes:

declare namespace IR$1 {
  ...
  export type Context<Spec extends Record<string, any> = any> = Context<Spec>;
  ...
}

which makes the type of Context to the type of itself, and thus TypeScript evaluates it to any.

Reproducible example or configuration

function f(schema: IR.SchemaObject, plugin: MyPlugin["Instance"]) {
  plugin.context.resolveIrRef(schema.$ref)
}

TypeScript now yells unsafe access to context which is any type.

OpenAPI specification (optional)

No response

System information (optional)

No response

Metadata

Metadata

Assignees

Labels

bug 🔥Something isn't workingjavascriptPull requests that update Javascript codeneeds info ⏳Further information is required

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions