mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Use MetaTableData more
Summary: Add more method overrides to MetaTableData for extra type safety. Use MetaTableData, MetaRowRecord, and getMetaTable in more places. Test Plan: Mostly it just has to compile. Tested manually that types are being checked more strictly now, e.g. by adding a typo to property names. Some type casting has also been removed. Reviewers: dsagal Reviewed By: dsagal Subscribers: dsagal Differential Revision: https://phab.getgrist.com/D3168
This commit is contained in:
@@ -5,10 +5,11 @@
|
||||
*/
|
||||
|
||||
import {DocComm} from 'app/client/components/DocComm';
|
||||
import {TableData} from 'app/client/models/TableData';
|
||||
import {MetaTableData, TableData} from 'app/client/models/TableData';
|
||||
import {ApplyUAOptions, ApplyUAResult} from 'app/common/ActiveDocAPI';
|
||||
import {CellValue, TableDataAction, UserAction} from 'app/common/DocActions';
|
||||
import {DocData as BaseDocData} from 'app/common/DocData';
|
||||
import {SchemaTypes} from 'app/common/schema';
|
||||
import {ColTypeMap} from 'app/common/TableData';
|
||||
import * as bluebird from 'bluebird';
|
||||
import {Emitter} from 'grainjs';
|
||||
@@ -51,6 +52,11 @@ export class DocData extends BaseDocData {
|
||||
return super.getTable(tableId) as TableData;
|
||||
}
|
||||
|
||||
// Version of inherited getMetaTable() which returns the enhanced TableData type.
|
||||
public getMetaTable<TableId extends keyof SchemaTypes>(tableId: TableId): MetaTableData<TableId> {
|
||||
return super.getMetaTable(tableId) as any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds up to n most likely target columns for the given values in the document.
|
||||
*/
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
/**
|
||||
* TableData maintains a single table's data.
|
||||
*/
|
||||
import { ColumnACIndexes } from 'app/client/models/ColumnACIndexes';
|
||||
import { ColumnCache } from 'app/client/models/ColumnCache';
|
||||
import { DocData } from 'app/client/models/DocData';
|
||||
import { DocAction, ReplaceTableData, TableDataAction, UserAction } from 'app/common/DocActions';
|
||||
import { isRaisedException } from 'app/common/gristTypes';
|
||||
import { countIf } from 'app/common/gutil';
|
||||
import { TableData as BaseTableData, ColTypeMap } from 'app/common/TableData';
|
||||
import { Emitter } from 'grainjs';
|
||||
import {ColumnACIndexes} from 'app/client/models/ColumnACIndexes';
|
||||
import {ColumnCache} from 'app/client/models/ColumnCache';
|
||||
import {DocData} from 'app/client/models/DocData';
|
||||
import {DocAction, ReplaceTableData, TableDataAction, UserAction} from 'app/common/DocActions';
|
||||
import {isRaisedException} from 'app/common/gristTypes';
|
||||
import {countIf} from 'app/common/gutil';
|
||||
import {SchemaTypes} from 'app/common/schema';
|
||||
import {ColTypeMap, MetaTableData as MetaTableDataBase, TableData as TableDataBase} from 'app/common/TableData';
|
||||
import {Emitter} from 'grainjs';
|
||||
|
||||
/**
|
||||
* TableData class to maintain a single table's data.
|
||||
*/
|
||||
export class TableData extends BaseTableData {
|
||||
export class TableData extends TableDataBase {
|
||||
public readonly tableActionEmitter = new Emitter();
|
||||
public readonly dataLoadedEmitter = new Emitter();
|
||||
|
||||
@@ -108,3 +109,5 @@ export class TableData extends BaseTableData {
|
||||
return applied;
|
||||
}
|
||||
}
|
||||
|
||||
export type MetaTableData<TableId extends keyof SchemaTypes> = MetaTableDataBase<TableId> & TableData;
|
||||
|
||||
Reference in New Issue
Block a user