SIGN IN SIGN UP
facebook / react-native UNCLAIMED

A framework for building native applications using React

0 0 155 C++

Add support for StringLiteralTypeAnnotation (#46827)

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

You can now define a native module that takes an argument that is a specific string literal:

Like this:
```
export interface Spec extends TurboModule {
  +passString: (arg: string) => void;
  +passStringLiteral: (arg: 'A String Literal') => void;
}
```

On the native side, this will still generate `string`, but the schema will now store the string literal, and it will be allowed in JS. This should allow more strict flow / typescript types for modules.

This will also allow the compatibility check to fail if the literal changes.

This is a step towards accepting a union of string literals.

Changelog: [General][Added] Codegen for Native Modules now supports string literals

Reviewed By: GijsWeterings

Differential Revision: D63872440

fbshipit-source-id: e54b97d34af4a3d1af51727db0777f26fb7b778c
E
Eli White committed
d2f3f06826e2287ad5f5dc4e27201fc5dc9fcd5c
Parent: 73ce198
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> on 10/7/2024, 7:35:19 PM