You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constschema={a: Number,b: String};typeSchemaType=typeofschema;classMyClassimplementsSchemaType{// ❌ TypeScript reports missing properties 'a' and 'b'// ❌ But VSCode does NOT scaffold them via Quick Fix ("Add missing members")// ❌ No autocomplete suggestions either}
However, if the same structure is wrapped in another object type, scaffolding does work:
typeWrapped={schema: typeofschema};classMyWrappedClassimplementsWrapped{schema={a: Number,b: String,};// ✅ IDE scaffolds 'schema.a' and 'schema.b' as expected}
Even more interesting: when using a schema-type library like computed-types, class scaffolding does work when implementing Type<typeof Schema(...)> — even though that ultimately derives from an object structure as well.
🙁 Actual behavior
Missing members are reported, but IDE does not scaffold them unless the type is wrapped. This makes working with typeof schemaObject types harder, despite TypeScript fully understanding what’s missing.
🙂 Expected behavior
When implementing a plain object type using typeof, TypeScript tooling (e.g. WebStorm) should provide the same scaffolding as it does with interface-like types or wrapper types. This would improve DX for common schema-driven design patterns.
Additional information about the issue
📌 Notes
This issue blocks ergonomic use of typeof for schemas in class-based design patterns (e.g., validation classes or model classes).
Possibly related to how typeof resolves to an anonymous object type, which the scaffolder might treat differently from named/interface types.
Libraries like computed-types somehow work around this by exposing types via Type that expand the structure enough for tooling to scaffold
Inside computed-types sources, the scaffolding doesn't happen either — only when used externally in a consumer project
It would be great if TypeScript + tooling could scaffold missing properties even when using typeof of a plain object in a class implementation — especially since this is a common pattern for schema-based design (validation, form definitions, etc.).
The text was updated successfully, but these errors were encountered:
🔎 Search Terms
typeof object
,implements
,missing properties
,scaffolding
,IDE
,VSCode
,class implements
,autocomplete
,schema typing
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play/?#code/C4TwDgpgBAKlC8UDeAoK6oEMBcUB2ArgLYBGEATgNxoYm4DOw5AlngOaVQoC+KKAxgHs8jKMATIa6HFACMAGilQ6UAOSzVPPqEhQAkngBmFCABM4iHREGGx1AQBtM9erADCTl1GZEwDiEQQeMCucKi8js6uBsbkZjAeUd6+-oHB0UYm5pJaKFZQAOrkmGCQphJIAO7FZbgxWTAR-J6uRSVl9eTJfgFBIYU1ZUi8QA
💻 Code
However, if the same structure is wrapped in another object type, scaffolding does work:
Even more interesting: when using a schema-type library like
computed-types
, class scaffolding does work when implementingType<typeof Schema(...)>
— even though that ultimately derives from an object structure as well.🙁 Actual behavior
Missing members are reported, but IDE does not scaffold them unless the type is wrapped. This makes working with
typeof schemaObject
types harder, despite TypeScript fully understanding what’s missing.🙂 Expected behavior
When implementing a plain object type using
typeof
, TypeScript tooling (e.g. WebStorm) should provide the same scaffolding as it does with interface-like types or wrapper types. This would improve DX for common schema-driven design patterns.Additional information about the issue
📌 Notes
typeof
for schemas in class-based design patterns (e.g., validation classes or model classes).typeof
resolves to an anonymous object type, which the scaffolder might treat differently from named/interface types.computed-types
somehow work around this by exposing types via Type that expand the structure enough for tooling to scaffoldcomputed-types
sources, the scaffolding doesn't happen either — only when used externally in a consumer projectIt would be great if TypeScript + tooling could scaffold missing properties even when using typeof of a plain object in a class implementation — especially since this is a common pattern for schema-based design (validation, form definitions, etc.).
The text was updated successfully, but these errors were encountered: