-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28306 from kubabutkiewicz/ts-migration/IntlPolyfi…
…ll-lib [No QA] [TS migration] Migrate 'IntlPolyfill' lib to TypeScript
- Loading branch information
Showing
5 changed files
with
14 additions
and
7 deletions.
There are no files selected for viewing
7 changes: 5 additions & 2 deletions
7
src/libs/IntlPolyfill/index.native.js → src/libs/IntlPolyfill/index.native.ts
This file contains 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 |
---|---|---|
@@ -1,15 +1,18 @@ | ||
import polyfillNumberFormat from './polyfillNumberFormat'; | ||
import polyfillListFormat from './polyfillListFormat'; | ||
import IntlPolyfill from './types'; | ||
|
||
/** | ||
* Polyfill the Intl API, always performed for native devices. | ||
*/ | ||
export default function polyfill() { | ||
const intlPolyfill: IntlPolyfill = () => { | ||
// Native devices require extra polyfills | ||
require('@formatjs/intl-getcanonicallocales/polyfill'); | ||
require('@formatjs/intl-locale/polyfill'); | ||
require('@formatjs/intl-pluralrules/polyfill'); | ||
require('@formatjs/intl-datetimeformat'); | ||
polyfillNumberFormat(); | ||
polyfillListFormat(); | ||
} | ||
}; | ||
|
||
export default intlPolyfill; |
6 changes: 4 additions & 2 deletions
6
src/libs/IntlPolyfill/index.js → src/libs/IntlPolyfill/index.ts
This file contains 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 |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import polyfillNumberFormat from './polyfillNumberFormat'; | ||
import IntlPolyfill from './types'; | ||
|
||
/** | ||
* Polyfill the Intl API if the ICU version is old. | ||
* This ensures that the currency data is consistent across platforms and browsers. | ||
*/ | ||
export default function intlPolyfill() { | ||
const intlPolyfill: IntlPolyfill = () => { | ||
// Just need to polyfill Intl.NumberFormat for web based platforms | ||
polyfillNumberFormat(); | ||
require('@formatjs/intl-datetimeformat'); | ||
} | ||
}; | ||
export default intlPolyfill; |
File renamed without changes.
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
type IntlPolyfill = () => void; | ||
|
||
export default IntlPolyfill; |