diff --git a/flow-typed/prettier_v1.x.x.js b/flow-typed/prettier_v1.x.x.js index 43c8c2437dc..39915be3681 100644 --- a/flow-typed/prettier_v1.x.x.js +++ b/flow-typed/prettier_v1.x.x.js @@ -122,21 +122,21 @@ declare module "prettier" { declare export type CursorOptions = {| cursorOffset: number, - printWidth?: $PropertyType, - tabWidth?: $PropertyType, - useTabs?: $PropertyType, - semi?: $PropertyType, - singleQuote?: $PropertyType, - trailingComma?: $PropertyType, - bracketSpacing?: $PropertyType, - jsxBracketSameLine?: $PropertyType, - arrowParens?: $PropertyType, - parser?: $PropertyType, - filepath?: $PropertyType, - requirePragma?: $PropertyType, - insertPragma?: $PropertyType, - proseWrap?: $PropertyType, - plugins?: $PropertyType + printWidth?: Options["printWidth"], + tabWidth?: Options["tabWidth"], + useTabs?: Options["useTabs"], + semi?: Options["semi"], + singleQuote?: Options["singleQuote"], + trailingComma?: Options["trailingComma"], + bracketSpacing?: Options["bracketSpacing"], + jsxBracketSameLine?: Options["jsxBracketSameLine"], + arrowParens?: Options["arrowParens"], + parser?: Options["parser"], + filepath?: Options["filepath"], + requirePragma?: Options["requirePragma"], + insertPragma?: Options["insertPragma"], + proseWrap?: Options["proseWrap"], + plugins?: Options["plugins"] |}; declare export type CursorResult = {| diff --git a/src/__tests__/lib/exampleData.js b/src/__tests__/lib/exampleData.js index f11251e1a40..7bb83ea17a9 100644 --- a/src/__tests__/lib/exampleData.js +++ b/src/__tests__/lib/exampleData.js @@ -187,19 +187,19 @@ export const makeCrossRealmBot = ( bot_type: 1, }); -export const userStatusEmojiUnicode: $PropertyType = deepFreeze({ +export const userStatusEmojiUnicode: UserStatus['status_emoji'] = deepFreeze({ reaction_type: 'unicode_emoji', emoji_code: '1f44d', emoji_name: 'thumbs_up', }); -export const userStatusEmojiZulipExtra: $PropertyType = deepFreeze({ +export const userStatusEmojiZulipExtra: UserStatus['status_emoji'] = deepFreeze({ reaction_type: 'zulip_extra_emoji', emoji_code: 'zulip', emoji_name: 'zulip', }); -export const userStatusEmojiRealm: $PropertyType = deepFreeze({ +export const userStatusEmojiRealm: UserStatus['status_emoji'] = deepFreeze({ reaction_type: 'realm_emoji', emoji_code: '80', emoji_name: 'github_parrot', @@ -983,7 +983,7 @@ export const action = Object.freeze({ */ export const mkActionRegisterComplete = (extra: {| ...$Rest, - unread_msgs?: $Rest<$PropertyType, { ... }>, + unread_msgs?: $Rest, |}): PerAccountAction => { const { unread_msgs, ...rest } = extra; return deepFreeze({ diff --git a/src/api/eventTypes.js b/src/api/eventTypes.js index 6483c3d2a95..b791975cd2a 100644 --- a/src/api/eventTypes.js +++ b/src/api/eventTypes.js @@ -175,16 +175,16 @@ export type StreamUpdateEvent = | {| ...StreamUpdateEventBase<'name'> |} | {| ...StreamUpdateEventBase<'description'>, - +rendered_description: $PropertyType, + +rendered_description: Stream['rendered_description'], |} // TODO(server-4.0): New in FL 30. | {| ...StreamUpdateEventBase<'date_created'> |} | {| ...StreamUpdateEventBase<'invite_only'>, - +history_public_to_subscribers: $PropertyType, + +history_public_to_subscribers: Stream['history_public_to_subscribers'], // TODO(server-5.0): New in FL 71. - +is_web_public?: $PropertyType, + +is_web_public?: Stream['is_web_public'], |} | {| ...StreamUpdateEventBase<'rendered_description'> |} | {| ...StreamUpdateEventBase<'is_web_public'> |} @@ -357,10 +357,10 @@ type PersonCommon = | SubsetProperties | SubsetProperties | {| - +user_id: $PropertyType, + +user_id: UserOrBot['user_id'], +custom_profile_field: {| +id: number, +value: string | null, +rendered_value?: string |}, |} - | {| +user_id: $PropertyType, +new_email: string |}; + | {| +user_id: UserOrBot['user_id'], +new_email: string |}; /** * A realm_user update event, straight from the server. diff --git a/src/api/realmDataTypes.js b/src/api/realmDataTypes.js index 59b170a3dad..618f143f0df 100644 --- a/src/api/realmDataTypes.js +++ b/src/api/realmDataTypes.js @@ -24,111 +24,111 @@ export type RealmDataForUpdate = $ReadOnly<{ // add_custom_emoji_policy: - $PropertyType, + InitialDataRealm['realm_add_custom_emoji_policy'], allow_community_topic_editing: // deprecated - $PropertyType, + InitialDataRealm['realm_allow_community_topic_editing'], allow_edit_history: - $PropertyType, + InitialDataRealm['realm_allow_edit_history'], allow_message_editing: - $PropertyType, + InitialDataRealm['realm_allow_message_editing'], authentication_methods: - $PropertyType, + InitialDataRealm['realm_authentication_methods'], bot_creation_policy: - $PropertyType, + InitialDataRealm['realm_bot_creation_policy'], community_topic_editing_limit_seconds: - $PropertyType, + InitialDataRealm['realm_community_topic_editing_limit_seconds'], create_private_stream_policy: - $PropertyType, + InitialDataRealm['realm_create_private_stream_policy'], create_public_stream_policy: - $PropertyType, + InitialDataRealm['realm_create_public_stream_policy'], create_web_public_stream_policy: - $PropertyType, + InitialDataRealm['realm_create_web_public_stream_policy'], create_stream_policy: // deprecated - $PropertyType, + InitialDataRealm['realm_create_stream_policy'], default_code_block_language: - $PropertyType, + InitialDataRealm['realm_default_code_block_language'], default_language: - $PropertyType, + InitialDataRealm['realm_default_language'], description: - $PropertyType, + InitialDataRealm['realm_description'], digest_emails_enabled: - $PropertyType, + InitialDataRealm['realm_digest_emails_enabled'], digest_weekday: - $PropertyType, + InitialDataRealm['realm_digest_weekday'], disallow_disposable_email_addresses: - $PropertyType, + InitialDataRealm['realm_disallow_disposable_email_addresses'], edit_topic_policy: - $PropertyType, + InitialDataRealm['realm_edit_topic_policy'], email_address_visibility: - $PropertyType, + InitialDataRealm['realm_email_address_visibility'], email_changes_disabled: - $PropertyType, + InitialDataRealm['realm_email_changes_disabled'], emails_restricted_to_domains: - $PropertyType, + InitialDataRealm['realm_emails_restricted_to_domains'], enable_spectator_access: - $PropertyType, + InitialDataRealm['realm_enable_spectator_access'], giphy_rating: - $PropertyType, + InitialDataRealm['realm_giphy_rating'], icon_source: - $PropertyType, + InitialDataRealm['realm_icon_source'], icon_url: - $PropertyType, + InitialDataRealm['realm_icon_url'], inline_image_preview: - $PropertyType, + InitialDataRealm['realm_inline_image_preview'], inline_url_embed_preview: - $PropertyType, + InitialDataRealm['realm_inline_url_embed_preview'], invite_by_admins_only: // deprecated - $PropertyType, + InitialDataRealm['realm_invite_by_admins_only'], invite_required: - $PropertyType, + InitialDataRealm['realm_invite_required'], invite_to_realm_policy: - $PropertyType, + InitialDataRealm['realm_invite_to_realm_policy'], invite_to_stream_policy: - $PropertyType, + InitialDataRealm['realm_invite_to_stream_policy'], logo_source: - $PropertyType, + InitialDataRealm['realm_logo_source'], logo_url: - $PropertyType, + InitialDataRealm['realm_logo_url'], mandatory_topics: - $PropertyType, + InitialDataRealm['realm_mandatory_topics'], message_content_allowed_in_email_notifications: - $PropertyType, + InitialDataRealm['realm_message_content_allowed_in_email_notifications'], message_content_delete_limit_seconds: - $PropertyType, + InitialDataRealm['realm_message_content_delete_limit_seconds'], message_content_edit_limit_seconds: - $PropertyType, + InitialDataRealm['realm_message_content_edit_limit_seconds'], move_messages_between_streams_policy: - $PropertyType, + InitialDataRealm['realm_move_messages_between_streams_policy'], name: - $PropertyType, + InitialDataRealm['realm_name'], name_changes_disabled: - $PropertyType, + InitialDataRealm['realm_name_changes_disabled'], night_logo_source: - $PropertyType, + InitialDataRealm['realm_night_logo_source'], night_logo_url: - $PropertyType, + InitialDataRealm['realm_night_logo_url'], notifications_stream_id: - $PropertyType, + InitialDataRealm['realm_notifications_stream_id'], plan_type: - $PropertyType, + InitialDataRealm['realm_plan_type'], presence_disabled: - $PropertyType, + InitialDataRealm['realm_presence_disabled'], private_message_policy: - $PropertyType, + InitialDataRealm['realm_private_message_policy'], send_welcome_emails: - $PropertyType, + InitialDataRealm['realm_send_welcome_emails'], signup_notifications_stream_id: - $PropertyType, + InitialDataRealm['realm_signup_notifications_stream_id'], user_group_edit_policy: - $PropertyType, + InitialDataRealm['realm_user_group_edit_policy'], video_chat_provider: - $PropertyType, + InitialDataRealm['realm_video_chat_provider'], waiting_period_threshold: - $PropertyType, + InitialDataRealm['realm_waiting_period_threshold'], want_advertise_in_communities_directory: - $PropertyType, + InitialDataRealm['realm_want_advertise_in_communities_directory'], wildcard_mention_policy: - $PropertyType, + InitialDataRealm['realm_wildcard_mention_policy'], // // Keep alphabetical by the InitialDataRealm property. So by diff --git a/src/api/streams/createStream.js b/src/api/streams/createStream.js index 8e906d03f86..8e106816c40 100644 --- a/src/api/streams/createStream.js +++ b/src/api/streams/createStream.js @@ -16,17 +16,17 @@ export default ( streamAttributes: $ReadOnly<{| // Ordered by their appearance in the doc. - name: $PropertyType, - description?: $PropertyType, - invite_only?: $PropertyType, + name: Stream['name'], + description?: Stream['description'], + invite_only?: Stream['invite_only'], // TODO(server-5.0): New in FL 98 - is_web_public?: $PropertyType, + is_web_public?: Stream['is_web_public'], - history_public_to_subscribers?: $PropertyType, + history_public_to_subscribers?: Stream['history_public_to_subscribers'], // TODO(server-3.0): New in FL 1; for older servers, pass is_announcement_only. - stream_post_policy?: $PropertyType, + stream_post_policy?: Stream['stream_post_policy'], // Doesn't take the same special values as Stream.message_retention_days! // https://chat.zulip.org/#narrow/stream/412-api-documentation/topic/message_retention_days/near/1367895 @@ -42,7 +42,7 @@ export default ( // TODO(server-3.0): Replaced in FL 1 by 'stream_post_policy'. // Commented out because this isn't actually in the doc. It probably // exists though? Copied from api.updateStream. - // is_announcement_only?: $PropertyType, + // is_announcement_only?: Stream['is_announcement_only'], |}>, options?: $ReadOnly<{| // TODO(server-3.0): Send numeric user IDs (#3764), not emails. diff --git a/src/api/streams/updateStream.js b/src/api/streams/updateStream.js index 74792ab9b7b..4463bb64de8 100644 --- a/src/api/streams/updateStream.js +++ b/src/api/streams/updateStream.js @@ -16,21 +16,21 @@ export default ( // TODO(#4659): Once we pass the feature level to API methods, this one // should encapsulate a switch at FL 64 related to these two parameters. // See call sites. - description?: $PropertyType, - new_name?: $PropertyType, + description?: Stream['description'], + new_name?: Stream['name'], // controls the invite_only property - is_private?: $PropertyType, + is_private?: Stream['invite_only'], // TODO(server-5.0): New in FL 98. - is_web_public?: $PropertyType, + is_web_public?: Stream['is_web_public'], // TODO(server-3.0): New in FL 1; for older servers, pass is_announcement_only. - stream_post_policy?: $PropertyType, + stream_post_policy?: Stream['stream_post_policy'], // N.B.: Don't pass this without also passing is_web_public; see // https://chat.zulip.org/#narrow/stream/378-api-design/topic/PATCH.20.2Fstreams.2F.7Bstream_id.7D/near/1383984 - history_public_to_subscribers?: $PropertyType, + history_public_to_subscribers?: Stream['history_public_to_subscribers'], // Doesn't take the same special values as Stream.message_retention_days! // https://chat.zulip.org/#narrow/stream/412-api-documentation/topic/message_retention_days/near/1367895 @@ -44,6 +44,6 @@ export default ( | 'forever', // TODO(server-3.0): Replaced in FL 1 by 'stream_post_policy'. - is_announcement_only?: $PropertyType, + is_announcement_only?: Stream['is_announcement_only'], |}>, ): Promise => apiPatch(auth, `streams/${id}`, params); diff --git a/src/common/Touchable.js b/src/common/Touchable.js index f1435650028..bede4e2efd9 100644 --- a/src/common/Touchable.js +++ b/src/common/Touchable.js @@ -9,7 +9,7 @@ import { HIGHLIGHT_COLOR } from '../styles'; type Props = $ReadOnly<{| accessibilityLabel?: string, style?: ViewStyleProp, - hitSlop?: $PropertyType, 'hitSlop'>, + hitSlop?: ElementConfig['hitSlop'], children: Node, onPress?: () => void | Promise, onLongPress?: () => void, diff --git a/src/common/ZulipStatusBar.js b/src/common/ZulipStatusBar.js index 2b6ea3eafec..bdbc92e6455 100644 --- a/src/common/ZulipStatusBar.js +++ b/src/common/ZulipStatusBar.js @@ -11,7 +11,7 @@ import { useGlobalSelector } from '../react-redux'; import { foregroundColorFromBackground } from '../utils/color'; import { getGlobalSession, getGlobalSettings } from '../selectors'; -type BarStyle = $PropertyType, 'barStyle'>; +type BarStyle = React$ElementConfig['barStyle']; export const getStatusBarColor = (backgroundColor: string | void, theme: ThemeName): string => backgroundColor ?? (theme === 'night' ? 'hsl(212, 28%, 18%)' : 'white'); diff --git a/src/react-navigation.js b/src/react-navigation.js index 2927561903f..85f82532668 100644 --- a/src/react-navigation.js +++ b/src/react-navigation.js @@ -76,10 +76,7 @@ export type RouteProp<+RouteName: string, +RouteParams: { ... } | void> = {| // $NonMaybeType will also eliminate: the navigator will never be interested // in passing one of those values anyway, so as far as it's concerned the // type expected for `route` might as well exclude them.) -export type RouteParamsOf<-C> = $PropertyType< - $NonMaybeType<$PropertyType, 'route'>>, - 'params', ->; +export type RouteParamsOf<-C> = $NonMaybeType['route']>['params']; /** * Exactly like `useNavigation` upstream, but more typed. diff --git a/src/types.js b/src/types.js index bd2dc580771..1bb2c0c1cde 100644 --- a/src/types.js +++ b/src/types.js @@ -413,7 +413,7 @@ export type MessageListElement = // type [number, number] with its two members marked as covariant. Flow // has no syntax for that yet. // eslint-disable-next-line no-unused-expressions -(k: $PropertyType): $ReadOnlyArray => k; +(k: MessageListElement['key']): $ReadOnlyArray => k; export type TimingItemType = {| text: string, diff --git a/src/user-statuses/UserStatusScreen.js b/src/user-statuses/UserStatusScreen.js index 093ec9a099e..af57c07e8b2 100644 --- a/src/user-statuses/UserStatusScreen.js +++ b/src/user-statuses/UserStatusScreen.js @@ -74,12 +74,11 @@ type Props = $ReadOnly<{| route: RouteProp<'user-status', void>, |}>; -const statusTextFromInputValue = (v: string): $PropertyType => - v.trim() || null; +const statusTextFromInputValue = (v: string): UserStatus['status_text'] => v.trim() || null; -const inputValueFromStatusText = (t: $PropertyType): string => t ?? ''; +const inputValueFromStatusText = (t: UserStatus['status_text']): string => t ?? ''; -const statusEmojiFromInputValue = (v: EmojiInputValue): $PropertyType => +const statusEmojiFromInputValue = (v: EmojiInputValue): UserStatus['status_emoji'] => v ? { emoji_name: v.name, @@ -88,7 +87,7 @@ const statusEmojiFromInputValue = (v: EmojiInputValue): $PropertyType): EmojiInputValue => +const inputValueFromStatusEmoji = (e: UserStatus['status_emoji']): EmojiInputValue => e ? { type: emojiTypeFromReactionType(e.reaction_type), diff --git a/src/users/__tests__/usersReducer-test.js b/src/users/__tests__/usersReducer-test.js index 20a128ad2ad..fc4f71469e1 100644 --- a/src/users/__tests__/usersReducer-test.js +++ b/src/users/__tests__/usersReducer-test.js @@ -68,7 +68,7 @@ describe('usersReducer', () => { // Tell ESLint to recognize `check` as a helper function that runs // assertions. /* eslint jest/expect-expect: ["error", { "assertFunctionNames": ["expect", "check"] }] */ - const check = >( + const check = ( personMaybeWithoutId: $Rest, expectedUser?: User, ) => { diff --git a/src/users/usersReducer.js b/src/users/usersReducer.js index 900fd36de57..2b96b9a986e 100644 --- a/src/users/usersReducer.js +++ b/src/users/usersReducer.js @@ -50,7 +50,7 @@ export default ( profile_data: (() => { if (person.custom_profile_field.value !== null) { return { - ...(user.profile_data: $PropertyType), + ...(user.profile_data: User['profile_data']), [person.custom_profile_field.id]: ({ value: person.custom_profile_field.value, rendered_value: person.custom_profile_field.rendered_value, @@ -61,7 +61,7 @@ export default ( // anything with `any`. Remove when doing so // doesn't stop Flow from catching something // wrong on `value` or `rendered_value`. - }: $Values<$NonMaybeType<$PropertyType>>), + }: $Values<$NonMaybeType>), }; } else { // eslint-disable-next-line no-unused-vars diff --git a/src/webview/html/message.js b/src/webview/html/message.js index 82ae02e3bc2..5d1fed08e92 100644 --- a/src/webview/html/message.js +++ b/src/webview/html/message.js @@ -183,7 +183,7 @@ export const flagsStateToStringList = (flags: FlagsState, id: number): $ReadOnly Object.keys(flags).filter(key => flags[key][id]); const senderEmojiStatus = ( - emoji: $PropertyType, + emoji: UserStatus['status_emoji'], allImageEmojiById: $ReadOnly<{| [id: string]: ImageEmojiType |}>, ): string => emoji diff --git a/types/react-intl.js.flow b/types/react-intl.js.flow index e106450821e..c4e18b7a3ff 100644 --- a/types/react-intl.js.flow +++ b/types/react-intl.js.flow @@ -146,9 +146,9 @@ interface DisplayNamesOptions { } interface DisplayNamesResolvedOptions { locale: string; - style: $NonMaybeType<$PropertyType>; - type: $NonMaybeType<$PropertyType>; - fallback: $NonMaybeType<$PropertyType>; + style: $NonMaybeType; + type: $NonMaybeType; + fallback: $NonMaybeType; } interface ElementPart { type: 'element'; @@ -218,7 +218,7 @@ declare export var FormattedDate: React$StatelessFunctionalComponent< declare export var FormattedDateParts: React$StatelessFunctionalComponent< FormatDateOptions & { value: Date | number | string, // Param of Intl.DateTimeFormat.prototype.format(), or `string` - children(val: $Call<$PropertyType, mixed[]>): React$Element | null, + children(val: $Call): React$Element | null, ... }, >; declare export var FormattedDisplayName: React$StatelessFunctionalComponent< @@ -250,7 +250,7 @@ declare export var FormattedNumber: React$StatelessFunctionalComponent< ... }, >; declare export var FormattedNumberParts: React$StatelessFunctionalComponent< - $PropertyType & { + Formatter['formatNumber'] & { // Param type of our IntlShape.formatNumber, alias of our // IntlFormatters.formatNumber value: number, @@ -258,7 +258,7 @@ declare export var FormattedNumberParts: React$StatelessFunctionalComponent< // Callers will get a Flow error until Flow adds a built-in // definition for Intl.NumberFormat.prototype.formatToParts(): // https://github.com/facebook/flow/issues/8859 - children(val: $Call<$PropertyType, mixed[]>): React$Element | null, + children(val: $Call): React$Element | null, ... }, >; declare export var FormattedPlural: React$StatelessFunctionalComponent> & { @@ -287,7 +287,7 @@ declare export var FormattedTime: React$StatelessFunctionalComponent< declare export var FormattedTimeParts: React$StatelessFunctionalComponent< FormatDateOptions & { value: Date | number | string, // Param of Intl.DateTimeFormat.prototype.format(), or `string` - children(val: $Call<$PropertyType, mixed[]>): React$Element | null, + children(val: $Call): React$Element | null, ... }, >; type Formatter = { @@ -393,11 +393,11 @@ export interface IntlFormatters { formatDateToParts( value: Date | number | string, // Param of Intl.DateTimeFormat.prototype.format(), or `string` opts?: FormatDateOptions, - ): $Call<$PropertyType, mixed[]>; + ): $Call; formatTimeToParts( value: Date | number | string, // Param of Intl.DateTimeFormat.prototype.format(), or `string` opts?: FormatDateOptions, - ): $Call<$PropertyType, mixed[]>; + ): $Call; formatRelativeTime( value: number, // First param of our RelativeTimeFormat.prototype.format() unit?: FormattableUnit, // Second param of our RelativeTimeFormat.prototype.format() @@ -414,11 +414,11 @@ export interface IntlFormatters { // Callers will get a Flow error until Flow adds a built-in // definition for Intl.NumberFormat.prototype.formatToParts(): // https://github.com/facebook/flow/issues/8859 - ): $Call<$PropertyType, mixed[]>; + ): $Call; formatPlural( value: number, // Param of Intl.PluralRules.prototype.select() opts?: FormatPluralOptions, - ): $Call<((...args: $FlowFixMe[]) => R) => R, $PropertyType>; + ): $Call<((...args: $FlowFixMe[]) => R) => R, typeof Intl.PluralRules['select']>; formatMessage( descriptor: MessageDescriptor, // The `+` was added to make the properties covariant rather @@ -836,7 +836,7 @@ declare var PART_TYPE: {| type PluralElement = { options: {| [key: ValidPluralRule]: PluralOrSelectOption |}, offset: number, - pluralType: $PropertyType, + pluralType: Intl$PluralRulesOptions['type'], ... } & BaseElement; interface PluralOrSelectOption { @@ -939,7 +939,7 @@ type RelativeTimeFormatNumberPart = { // Callers will get a Flow error until Flow adds a built-in // definition for Intl.NumberFormat.prototype.formatToParts(): // https://github.com/facebook/flow/issues/8859 -} & $ElementType<$Call<$PropertyType, mixed[]>, number>; +} & $ElementType<$Call, number>; type RelativeTimeLocaleData = LocaleData; interface ResolvedIntlListFormatOptions { /**