Skip to content

Add support for StringLiteralTypeAnnotation#46827

Closed
elicwhite wants to merge 1 commit into
facebook:mainfrom
elicwhite:export-D63872440
Closed

Add support for StringLiteralTypeAnnotation#46827
elicwhite wants to merge 1 commit into
facebook:mainfrom
elicwhite:export-D63872440

Conversation

@elicwhite
Copy link
Copy Markdown
Member

Summary:
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

Differential Revision: D63872440

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 4, 2024
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D63872440

Summary:

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
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D63872440

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request has been merged in d2f3f06.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Oct 7, 2024
@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @elicwhite in d2f3f06

When will my fix make it into a release? | How to file a pick request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants