mirror of
https://github.com/go-gitea/gitea
synced 2026-02-03 10:00:37 +00:00
Removes `@ts-expect-error` in the code base and forbids it. --------- Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: silverwind <115237+silverwind@users.noreply.github.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
34 lines
1010 B
TypeScript
34 lines
1010 B
TypeScript
try {
|
|
// some browsers like PaleMoon don't have full support for Intl.NumberFormat, so do the minimum polyfill to support "relative-time-element"
|
|
// https://repo.palemoon.org/MoonchildProductions/UXP/issues/2289
|
|
new Intl.NumberFormat('en', {style: 'unit', unit: 'minute'}).format(1);
|
|
} catch {
|
|
const intlNumberFormat = Intl.NumberFormat;
|
|
Intl.NumberFormat = function(locales: string | string[], options: Intl.NumberFormatOptions) {
|
|
if (options.style === 'unit') {
|
|
return {
|
|
format(value: number | bigint | string) {
|
|
return ` ${value} ${options.unit}`;
|
|
},
|
|
} as Intl.NumberFormat;
|
|
}
|
|
return intlNumberFormat(locales, options);
|
|
} as unknown as typeof Intl.NumberFormat;
|
|
}
|
|
|
|
export function weakRefClass() {
|
|
const weakMap = new WeakMap();
|
|
return class {
|
|
constructor(target: any) {
|
|
weakMap.set(this, target);
|
|
}
|
|
deref() {
|
|
return weakMap.get(this);
|
|
}
|
|
};
|
|
}
|
|
|
|
if (!window.WeakRef) {
|
|
window.WeakRef = weakRefClass() as any;
|
|
}
|