Skip to content

Commit 1eebb5a

Browse files
panagosg7facebook-github-bot
authored andcommitted
Back out "add 'as const' annotations in preparation of natural inference rollout in xplat/js [4/n]"
Summary: Original commit changeset: 67ee5673816d Original Phabricator Diff: D75114154 Reviewed By: SamChou19815 Differential Revision: D75161840 fbshipit-source-id: 144fc0e488154b957f4f2a549c077a2784124849
1 parent 6e50603 commit 1eebb5a

16 files changed

Lines changed: 81 additions & 90 deletions

File tree

packages/react-native-babel-transformer/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ const transform /*: BabelTransformer['transform'] */ = ({
190190
try {
191191
const babelConfig = {
192192
// ES modules require sourceType='module' but OSS may not always want that
193-
sourceType: 'unambiguous' as const,
193+
sourceType: 'unambiguous',
194194
...buildBabelConfig(filename, options, plugins),
195195
caller: {name: 'metro', bundler: 'metro', platform: options.platform},
196196
ast: true,

packages/react-native-compatibility-check/src/VersionDiffing.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -977,14 +977,14 @@ function buildNativeModulesDiff(
977977
);
978978

979979
const newType = {
980-
type: 'ObjectTypeAnnotation' as const,
980+
type: 'ObjectTypeAnnotation',
981981
properties: [
982982
...newerNativeModule.spec.methods,
983983
...newerNativeModule.spec.eventEmitters,
984984
],
985985
};
986986
const oldType = {
987-
type: 'ObjectTypeAnnotation' as const,
987+
type: 'ObjectTypeAnnotation',
988988
properties: [
989989
...olderNativeModule.spec.methods,
990990
...olderNativeModule.spec.eventEmitters,
@@ -1074,13 +1074,13 @@ function buildNativeComponentsDiff(
10741074
);
10751075

10761076
const newCommands = {
1077-
type: 'ObjectTypeAnnotation' as const,
1077+
type: 'ObjectTypeAnnotation',
10781078
properties: [command],
10791079
};
10801080
const oldCommands =
10811081
oldCommand != null
10821082
? {
1083-
type: 'ObjectTypeAnnotation' as const,
1083+
type: 'ObjectTypeAnnotation',
10841084
properties: [oldCommand],
10851085
}
10861086
: null;
@@ -1124,15 +1124,15 @@ function buildNativeComponentsDiff(
11241124
// We have to do this to remove the .defaults from the props and get it into
11251125
// standard JavaScript shapes.
11261126
const newConvertedProps = {
1127-
type: 'ObjectTypeAnnotation' as const,
1127+
type: 'ObjectTypeAnnotation',
11281128
properties: newerComponent.props.map(prop => ({
11291129
name: prop.name,
11301130
optional: prop.optional,
11311131
typeAnnotation: convertPropToBasicTypes(prop.typeAnnotation),
11321132
})),
11331133
};
11341134
const oldConvertedProps = {
1135-
type: 'ObjectTypeAnnotation' as const,
1135+
type: 'ObjectTypeAnnotation',
11361136
properties: olderComponent.props.map(prop => ({
11371137
name: prop.name,
11381138
optional: prop.optional,

packages/react-native-fantom/runner/runner.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ async function processRNTesterCommandResult(
7474
parsed = JSON.parse(line);
7575
} catch {
7676
parsed = {
77-
type: 'console-log' as const,
78-
level: 'info' as const,
77+
type: 'console-log',
78+
level: 'info',
7979
message: line,
8080
};
8181
}

packages/react-native-fantom/runtime/setup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,10 @@ function runSpec(spec: Spec): TestCaseResult {
331331
spec.implementation();
332332
invokeHooks(spec.parentContext, 'afterEachHooks');
333333

334-
status = 'passed' as const;
334+
status = 'passed';
335335
} catch (e) {
336336
error = e;
337-
status = 'failed' as const;
337+
status = 'failed';
338338
}
339339

340340
result.status = status;

packages/react-native/Libraries/Modal/Modal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ class Modal extends React.Component<ModalProps, ModalState> {
279279
: this.props.backdropColor ?? 'white',
280280
};
281281

282-
let animationType = this.props.animationType || ('none' as const);
282+
let animationType = this.props.animationType || 'none';
283283

284284
let presentationStyle = this.props.presentationStyle;
285285
if (!presentationStyle) {

packages/react-native/Libraries/NativeComponent/__tests__/StaticViewConfigValidator-test.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ test('passes for identical configs', () => {
4040
},
4141
uiViewClassName: 'RCTView',
4242
validAttributes: {
43-
collapsable: true as const,
44-
nativeID: true as const,
43+
collapsable: true,
44+
nativeID: true,
4545
style: {
46-
height: true as const,
47-
width: true as const,
46+
height: true,
47+
width: true,
4848
},
4949
},
5050
};
@@ -70,11 +70,11 @@ test('passes for identical configs', () => {
7070
},
7171
uiViewClassName: 'RCTView',
7272
validAttributes: {
73-
collapsable: true as const,
74-
nativeID: true as const,
73+
collapsable: true,
74+
nativeID: true,
7575
style: {
76-
height: true as const,
77-
width: true as const,
76+
height: true,
77+
width: true,
7878
},
7979
},
8080
};
@@ -190,11 +190,11 @@ test('allows static viewconfigs to have more properties than native viewconfigs'
190190
const staticViewConfig = {
191191
uiViewClassName: 'RCTView',
192192
validAttributes: {
193-
collapsable: true as const,
194-
nativeID: true as const,
193+
collapsable: true,
194+
nativeID: true,
195195
style: {
196-
height: true as const,
197-
width: true as const,
196+
height: true,
197+
width: true,
198198
},
199199
},
200200
};

packages/react-native/Libraries/Text/Text.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,10 +541,10 @@ const userSelectToSelectableMap = {
541541
};
542542

543543
const verticalAlignToTextAlignVerticalMap = {
544-
auto: 'auto' as const,
545-
top: 'top' as const,
546-
bottom: 'bottom' as const,
547-
middle: 'center' as const,
544+
auto: 'auto',
545+
top: 'top',
546+
bottom: 'bottom',
547+
middle: 'center',
548548
};
549549

550550
export default TextImpl;

packages/react-native/Libraries/Text/TextNativeComponent.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,23 @@ export type NativeTextProps = $ReadOnly<{
3030

3131
const textViewConfig = {
3232
validAttributes: {
33-
isHighlighted: true as const,
34-
isPressable: true as const,
35-
numberOfLines: true as const,
36-
ellipsizeMode: true as const,
37-
allowFontScaling: true as const,
38-
dynamicTypeRamp: true as const,
39-
maxFontSizeMultiplier: true as const,
40-
disabled: true as const,
41-
selectable: true as const,
42-
selectionColor: true as const,
43-
adjustsFontSizeToFit: true as const,
44-
minimumFontScale: true as const,
45-
textBreakStrategy: true as const,
46-
onTextLayout: true as const,
47-
dataDetectorType: true as const,
48-
android_hyphenationFrequency: true as const,
49-
lineBreakStrategyIOS: true as const,
33+
isHighlighted: true,
34+
isPressable: true,
35+
numberOfLines: true,
36+
ellipsizeMode: true,
37+
allowFontScaling: true,
38+
dynamicTypeRamp: true,
39+
maxFontSizeMultiplier: true,
40+
disabled: true,
41+
selectable: true,
42+
selectionColor: true,
43+
adjustsFontSizeToFit: true,
44+
minimumFontScale: true,
45+
textBreakStrategy: true,
46+
onTextLayout: true,
47+
dataDetectorType: true,
48+
android_hyphenationFrequency: true,
49+
lineBreakStrategyIOS: true,
5050
},
5151
directEventTypes: {
5252
topTextLayout: {
@@ -58,9 +58,9 @@ const textViewConfig = {
5858

5959
const virtualTextViewConfig = {
6060
validAttributes: {
61-
isHighlighted: true as const,
62-
isPressable: true as const,
63-
maxFontSizeMultiplier: true as const,
61+
isHighlighted: true,
62+
isPressable: true,
63+
maxFontSizeMultiplier: true,
6464
},
6565
uiViewClassName: 'RCTVirtualText',
6666
};

packages/react-native/scripts/ios-prebuild/hermes.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,9 @@ type HermesEngineSourceType =
9797
*/
9898

9999
const HermesEngineSourceTypes = {
100-
LOCAL_PREBUILT_TARBALL: 'local_prebuilt_tarball' as const,
101-
DOWNLOAD_PREBUILD_TARBALL: 'download_prebuild_tarball' as const,
102-
DOWNLOAD_PREBUILT_NIGHTLY_TARBALL:
103-
'download_prebuilt_nightly_tarball' as const,
100+
LOCAL_PREBUILT_TARBALL: 'local_prebuilt_tarball',
101+
DOWNLOAD_PREBUILD_TARBALL: 'download_prebuild_tarball',
102+
DOWNLOAD_PREBUILT_NIGHTLY_TARBALL: 'download_prebuilt_nightly_tarball',
104103
};
105104

106105
/**

packages/react-native/src/private/animated/__tests__/createAnimatedPropsMemoHook-test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ describe('createCompositeKeyForProps', () => {
2020
it('excludes non-array and non-object allowlisted props', () => {
2121
const props = {string: 'abc', number: 123, boolean: true, function() {}};
2222
const allowlist = {
23-
string: true as const,
24-
number: true as const,
25-
boolean: true as const,
26-
function: true as const,
23+
string: true,
24+
number: true,
25+
boolean: true,
26+
function: true,
2727
};
2828
const compositeKey = createCompositeKeyForProps(props, allowlist);
2929

@@ -53,7 +53,7 @@ describe('createCompositeKeyForProps', () => {
5353
bar: new AnimatedEvent([], {useNativeDriver: true}),
5454
};
5555
const allowlist = {
56-
bar: true as const,
56+
bar: true,
5757
};
5858
const compositeKey = createCompositeKeyForProps(props, allowlist);
5959

@@ -70,7 +70,7 @@ describe('createCompositeKeyForProps', () => {
7070
};
7171
const allowlist = {
7272
style: {
73-
baz: true as const,
73+
baz: true,
7474
},
7575
};
7676
const compositeKey = createCompositeKeyForProps(props, allowlist);
@@ -84,7 +84,7 @@ describe('createCompositeKeyForProps', () => {
8484
bar: new AnimatedValue(1),
8585
};
8686
const allowlist = {
87-
bar: true as const,
87+
bar: true,
8888
};
8989
const compositeKey = createCompositeKeyForProps(props, allowlist);
9090

@@ -108,7 +108,7 @@ describe('createCompositeKeyForProps', () => {
108108
const props = {
109109
style: {opacity, transform: [{rotateX: 1}, {rotateY}, {rotateZ: 1}]},
110110
};
111-
const allowlist = {style: {transform: true as const}};
111+
const allowlist = {style: {transform: true}};
112112
const compositeKey = createCompositeKeyForProps(props, allowlist);
113113

114114
expect(compositeKey).toEqual({
@@ -126,7 +126,7 @@ describe('createCompositeKeyForProps', () => {
126126
const props = {
127127
style: [{opacity: opacityA}, {opacity: opacityB}],
128128
};
129-
const allowlist = {style: {opacity: true as const}};
129+
const allowlist = {style: {opacity: true}};
130130
const compositeKey = createCompositeKeyForProps(props, allowlist);
131131

132132
expect(compositeKey).toEqual({style: {opacity: opacityB}});

0 commit comments

Comments
 (0)