Files
react-native/packages/react-native/types
Peter Xu b0a9053e67 Update typings for StyleSheet.create to catch typos in style keys (#39225)
Summary:
Previously, when you tried to create some styles using `StyleSheet.create`, you can create styles with invalid styles:

```ts
const styles = StyleSheet.create({
  container: {
    marginLeft: 1,
    magrinRight: 1, // This is a typo, but would not cause typecheck errors
  },
});
```

The root cause is that Typescript uses a looser [Excess Property Checks](https://www.typescriptlang.org/docs/handbook/2/objects.html#excess-property-checks) if we're using template types rather than using the actual specific types in the function signature.

- https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/62481

## Changelog:

[INTERNAL] [FIXED] - Make StyleSheet.create better check property keys for typos

Pull Request resolved: https://github.com/facebook/react-native/pull/39225

Test Plan: Added a test in __typeTests__, which should get run by CI.

Reviewed By: rshest

Differential Revision: D48859679

Pulled By: NickGerleman

fbshipit-source-id: 43aa69cf85cd69353d053b782dba73ab2027eb64
2023-09-01 21:40:37 -07:00
..