Stronger type for Schema
See original GitHub issueHello,
right now Schema
type is defined as:
export interface Schema {
/** `destinationProperty` is the name of the property of the target object you want to produce */
[destinationProperty: string]: ActionString | ActionFunction | ActionAggregator | ActionSelector;
}
What do you think about changing it to:
export interface Schema<Target> {
/** `destinationProperty` is the name of the property of the target object you want to produce */
[destinationProperty in keyof Target]: ActionString | ActionFunction | ActionAggregator | ActionSelector;
}
It will enforce you to map all fields in the target type, so you won’t miss any of them by mistake.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Types of Schema Markup in SEO: Picking the Right Structured ...
What are popular types of schema? Popular schema include: product markup, search action, FAQ schema, event schema, and more.
Read more >Organization of Schemas
Schema.org is a set of extensible schemas that enables webmasters to embed ... The schemas are a set of 'types', each associated with...
Read more >Multiple Types - JSON Schema
The basic declaration of multiple types is through the "type" keyword, ... This schema specifies both integers that are greater than or equal...
Read more >Schema Evolution and Compatibility - Confluent Documentation
The compatibility type determines how Schema Registry compares the new schema with previous versions of a schema, for a given subject. When a...
Read more >9 Most Common Schema Markup Types - Overdrive Interactive
Correspondingly, there are hundreds of markup types that can boost your ranking in search results.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello @bossqone,
Thank you for this suggestion! In fact I was thinking about strengthening the link between the Schema and the Target type. Typescript interface does not accepts lookup in keys for index signature it will probably be
It will be like
I would prefer not to enforce the consumer to specify each property since
Morphism
will automatically map properties when a Class Type is provided.I just opened a PR here https://github.com/nobrainr/morphism/pull/34, what do you think about ?