gristlabs_grist-core/app/common/declarations.d.ts

28 lines
634 B
TypeScript
Raw Permalink Normal View History

declare module "app/common/MemBuffer" {
const MemBuffer: any;
type MemBuffer = any;
export = MemBuffer;
}
declare module "locale-currency/map" {
const Map: Record<string, string>;
type Map = Record<string, string>;
export = Map;
}
declare namespace Intl {
class DisplayNames {
public static supportedLocalesOf(locales: string | string[]): string[];
constructor(locales?: string, options?: object);
public of(code: string): string;
}
class Locale {
public region: string;
public language: string;
constructor(locale: string);
}
}
(core) Guess date format during type conversion Summary: - Adds a dependency moment-guess (https://github.com/apoorv-mishra/moment-guess) to guess date formats from strings. However the npm package is missing source maps which leads to an ugly warning, so currently using a fork until https://github.com/apoorv-mishra/moment-guess/pull/22 is resolved. - Adds guessDateFormat using moment-guess to determine the best candidate date format. The logic may be refined for e.g. lossless imports where the stakes are higher, but for now we're just trying to make type conversions smoother. - Uses guessDateFormat to guess widget options when changing column type to date or datetime. - Uses the date format of the original column when possible instead of guessing. - Fixes a bug where choices were guessed based on the display column instead of the visible column, which made the guessed choices influenced by which values were referenced as well as completely broken when converting from reflist. - @dsagal @georgegevoian This builds on https://phab.getgrist.com/D3265, currently unmerged. That diff was created first to alert to the change. Without it there would still be similar test failures/changes here as the date format would often be concretely guessed and saved as YYYY-MM-DD instead of being left as the default `undefined` which is shows as YYYY-MM-DD in the dropdown. Test Plan: Added a unit test to `parseDate.ts`. Updated several browser tests which show the guessing in action during type conversion quite nicely. Reviewers: georgegevoian Reviewed By: georgegevoian Subscribers: dsagal, georgegevoian Differential Revision: https://phab.getgrist.com/D3264
2022-02-21 14:45:17 +00:00
declare module '@gristlabs/moment-guess/dist/bundle.js';