Search Terms
object literal class instance
treat object literal as class instance
Suggestion
According to this part of documentation, object literal is type-checked more strictly than other objects for excess properties. It would be nice to have feature to check excess properties for other "non-literal" objects such as class instances.
Use Cases
Let's say we have data fetched from database. It would include createdAt, updatedAt, or something like passwordHash. Some properties are not the best to get out of server.
When sending the data to client, I defined the payload type to not include those excess properties, but if the data is an form of class instance, the excess properties are allowed.
Examples
Playground link
Checklist
My suggestion meets these guidelines:
Search Terms
object literal class instancetreat object literal as class instanceSuggestion
According to this part of documentation, object literal is type-checked more strictly than other objects for excess properties. It would be nice to have feature to check excess properties for other "non-literal" objects such as class instances.
Use Cases
Let's say we have data fetched from database. It would include
createdAt,updatedAt, or something likepasswordHash. Some properties are not the best to get out of server.When sending the data to client, I defined the payload type to not include those excess properties, but if the data is an form of class instance, the excess properties are allowed.
Examples
Playground link
Checklist
My suggestion meets these guidelines: