Page MenuHomePhabricator

[keyserver] Add type workaround for Intl.Segmenter
ClosedPublic

Authored by inka on Mar 29 2023, 9:27 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Mar 13, 12:00 AM
Unknown Object (File)
Thu, Mar 7, 12:38 PM
Unknown Object (File)
Thu, Mar 7, 11:54 AM
Unknown Object (File)
Thu, Mar 7, 10:32 AM
Unknown Object (File)
Thu, Mar 7, 9:47 AM
Unknown Object (File)
Thu, Mar 7, 7:17 AM
Unknown Object (File)
Tue, Mar 5, 9:10 PM
Unknown Object (File)
Tue, Mar 5, 9:09 PM
Subscribers

Details

Summary

As discussed in D7077 we want to add type definition for Intl, because the type provided by flow doesn't include Segmenter field we need.
Here are the typescript types: https://github.com/microsoft/TypeScript/blob/main/src/lib/es2022.intl.d.ts

Test Plan

run flow in keyserver/. Checked that it is possible to use segment method of the returned object

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

inka requested review of this revision.Mar 29 2023, 9:42 AM
ashoat requested changes to this revision.Mar 29 2023, 1:03 PM
ashoat added inline comments.
keyserver/src/utils/segmenter.js
48 ↗(On Diff #24336)

We should not be returning an any type... this ruins all of the work you've done elsewhere in the file.

You would have the same effect if you replaced this whole file with this:

function getSegmenter(): any {
  return new Intl.Segmenter('eng', { granularity: 'word' });
}

Did you try using Segmenter instead of any here? Perhaps you tried that but got some Flow errors? We should try to resolve those errors.

This revision now requires changes to proceed.Mar 29 2023, 1:03 PM
keyserver/src/utils/segmenter.js
48 ↗(On Diff #24336)

Of course, this is a mistake. I forgot to change this after I wrote all types

This revision is now accepted and ready to land.Mar 30 2023, 2:53 PM