Revert "Chore: Update typescript to 4.9.3 (#60538)" (#60774)

This reverts commit 51f5334748.
This commit is contained in:
Dominik Prokop
2022-12-27 06:30:52 -08:00
committed by GitHub
parent 0d65063d0b
commit 9b7418ec17
17 changed files with 58 additions and 57 deletions

View File

@@ -89,7 +89,7 @@
"rollup-plugin-esbuild": "5.0.0",
"rollup-plugin-node-externals": "^5.0.0",
"sinon": "14.0.1",
"typescript": "4.9.3"
"typescript": "4.8.4"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0",

View File

@@ -32,23 +32,19 @@ export function hexToRgb(color: string) {
color = color.slice(1);
const re = new RegExp(`.{1,${color.length >= 6 ? 2 : 1}}`, 'g');
const result = color.match(re);
if (!result) {
return '';
}
let colors = Array.from(result);
let colors = color.match(re);
if (colors[0].length === 1) {
if (colors && colors[0].length === 1) {
colors = colors.map((n) => n + n);
}
const segments = colors
.map((n, index) => {
return index < 3 ? parseInt(n, 16) : Math.round((parseInt(n, 16) / 255) * 1000) / 1000;
})
.join(', ');
return `rgb${colors.length === 4 ? 'a' : ''}(${segments})`;
return colors
? `rgb${colors.length === 4 ? 'a' : ''}(${colors
.map((n, index) => {
return index < 3 ? parseInt(n, 16) : Math.round((parseInt(n, 16) / 255) * 1000) / 1000;
})
.join(', ')})`
: '';
}
function intToHex(int: number) {