microsoft / microsoft/react-native-windows

Improve config schema validation

Open
#7,439 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area: CLI enhancement PR Follow-up Workstream: Developer Experience
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.