microsoft / microsoft/react-native-windows
Improve config schema validation
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 17.3k
- Forks
- 1.2k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 33
Description
Is the intention here to allow null but not empty string?
Maybe not for now, but I've noticed a lot of the schema validation code here is tricky. There are some libraries we use in other places to automate this (e.g. io-ts), where it's quite simple to define a schema as a TS type and check an object against it at runtime. Would be nice to look at something like that, since it would reduce bug-surface, do more type checks, and enforce our TS types are correct.
E.g. this is how we declaratively define part of the overrides.json schema in Serialized.ts
/**
* Serialized form of {@see PatchOverride}
*/
const PatchOverrideType = t.type({
type: t.literal('patch'),
file: t.string,
baseFile: t.string,
baseVersion: t.union([t.undefined, t.string]),
baseHash: t.string,
issue: t.union([t.undefined, t.number]),
});
Originally posted by @NickGerleman in https://github.com/microsoft/react-native-windows/pull/7438#discussion_r598198068
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the schema validation code referenced in the issue and the Serialized.ts example for the overrides.json schema. Investigate whether io-ts or a comparable approach can cover the existing validation and TypeScript types. Done means the validation strategy is agreed, the relevant schemas are migrated or clearly scoped, and null versus empty-string behavior is defined.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100