-
Notifications
You must be signed in to change notification settings - Fork 49.9k
[compiler] Add types for WeakMap, WeakSet, and reanimated shared values #33077
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f9f7e02
[compiler] Add types for WeakMap, WeakSet, and reanimated shared values
josephsavona 42c6348
Update on "[compiler] Add types for WeakMap, WeakSet, and reanimated …
josephsavona 6f45e9d
Update on "[compiler] Add types for WeakMap, WeakSet, and reanimated …
josephsavona c99bb3f
Update on "[compiler] Add types for WeakMap, WeakSet, and reanimated …
josephsavona File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -203,6 +203,8 @@ export const BuiltInPropsId = 'BuiltInProps'; | |
| export const BuiltInArrayId = 'BuiltInArray'; | ||
| export const BuiltInSetId = 'BuiltInSet'; | ||
| export const BuiltInMapId = 'BuiltInMap'; | ||
| export const BuiltInWeakSetId = 'BuiltInWeakSet'; | ||
| export const BuiltInWeakMapId = 'BuiltInWeakMap'; | ||
| export const BuiltInFunctionId = 'BuiltInFunction'; | ||
| export const BuiltInJsxId = 'BuiltInJsx'; | ||
| export const BuiltInObjectId = 'BuiltInObject'; | ||
|
|
@@ -225,6 +227,9 @@ export const BuiltInStartTransitionId = 'BuiltInStartTransition'; | |
| export const BuiltInFireId = 'BuiltInFire'; | ||
| export const BuiltInFireFunctionId = 'BuiltInFireFunction'; | ||
|
|
||
| // See getReanimatedModuleType() in Globals.ts — this is part of supporting Reanimated's ref-like types | ||
| export const ReanimatedSharedValueId = 'ReanimatedSharedValueId'; | ||
|
|
||
| // ShapeRegistry with default definitions for built-ins. | ||
| export const BUILTIN_SHAPES: ShapeRegistry = new Map(); | ||
|
|
||
|
|
@@ -764,6 +769,101 @@ addObject(BUILTIN_SHAPES, BuiltInMapId, [ | |
| ], | ||
| ]); | ||
|
|
||
| addObject(BUILTIN_SHAPES, BuiltInWeakSetId, [ | ||
| [ | ||
| /** | ||
| * add(value) | ||
| * Parameters | ||
| * value: the value of the element to add to the Set object. | ||
| * Returns the Set object with added value. | ||
| */ | ||
| 'add', | ||
| addFunction(BUILTIN_SHAPES, [], { | ||
| positionalParams: [Effect.Capture], | ||
| restParam: null, | ||
| returnType: {kind: 'Object', shapeId: BuiltInSetId}, | ||
| calleeEffect: Effect.Store, | ||
| // returnValueKind is technically dependent on the ValueKind of the set itself | ||
| returnValueKind: ValueKind.Mutable, | ||
| }), | ||
| ], | ||
| [ | ||
| /** | ||
| * setInstance.delete(value) | ||
| * Returns true if value was already in Set; otherwise false. | ||
| */ | ||
| 'delete', | ||
| addFunction(BUILTIN_SHAPES, [], { | ||
| positionalParams: [Effect.Read], | ||
| restParam: null, | ||
| returnType: PRIMITIVE_TYPE, | ||
| calleeEffect: Effect.Store, | ||
| returnValueKind: ValueKind.Primitive, | ||
| }), | ||
| ], | ||
| [ | ||
| 'has', | ||
| addFunction(BUILTIN_SHAPES, [], { | ||
| positionalParams: [Effect.Read], | ||
| restParam: null, | ||
| returnType: PRIMITIVE_TYPE, | ||
| calleeEffect: Effect.Read, | ||
| returnValueKind: ValueKind.Primitive, | ||
| }), | ||
| ], | ||
| ]); | ||
|
|
||
| addObject(BUILTIN_SHAPES, BuiltInWeakMapId, [ | ||
| [ | ||
| 'delete', | ||
| addFunction(BUILTIN_SHAPES, [], { | ||
| positionalParams: [Effect.Read], | ||
| restParam: null, | ||
| returnType: PRIMITIVE_TYPE, | ||
| calleeEffect: Effect.Store, | ||
| returnValueKind: ValueKind.Primitive, | ||
| }), | ||
| ], | ||
| [ | ||
| 'get', | ||
| addFunction(BUILTIN_SHAPES, [], { | ||
| positionalParams: [Effect.Read], | ||
| restParam: null, | ||
| returnType: {kind: 'Poly'}, | ||
| calleeEffect: Effect.Capture, | ||
| returnValueKind: ValueKind.Mutable, | ||
| }), | ||
| ], | ||
| [ | ||
| 'has', | ||
| addFunction(BUILTIN_SHAPES, [], { | ||
| positionalParams: [Effect.Read], | ||
| restParam: null, | ||
| returnType: PRIMITIVE_TYPE, | ||
| calleeEffect: Effect.Read, | ||
| returnValueKind: ValueKind.Primitive, | ||
| }), | ||
| ], | ||
| [ | ||
| /** | ||
| * Params | ||
| * key: the key of the element to add to the Map object. The key may be | ||
| * any JavaScript type (any primitive value or any type of JavaScript | ||
| * object). | ||
| * value: the value of the element to add to the Map object. | ||
| * Returns the Map object. | ||
| */ | ||
| 'set', | ||
| addFunction(BUILTIN_SHAPES, [], { | ||
| positionalParams: [Effect.Capture, Effect.Capture], | ||
| restParam: null, | ||
| returnType: {kind: 'Object', shapeId: BuiltInMapId}, | ||
|
||
| calleeEffect: Effect.Store, | ||
| returnValueKind: ValueKind.Mutable, | ||
| }), | ||
| ], | ||
| ]); | ||
|
|
||
| addObject(BUILTIN_SHAPES, BuiltInUseStateId, [ | ||
| ['0', {kind: 'Poly'}], | ||
| [ | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: returns
BuiltInWeakSetId