Chore: Improve typings (#78940)
* improve typings * transformations typings improvements * add bootData to window * more grafana-data fixes * undo window.grafanaBootData typings
This commit is contained in:
@@ -46,7 +46,12 @@ describe('dataFrameView', () => {
|
||||
it('Should support array indexes', () => {
|
||||
expect(vector.length).toEqual(3);
|
||||
|
||||
const first = vector.get(0) as any;
|
||||
const first = vector.get(0) as unknown as [
|
||||
MySpecialObject['time'],
|
||||
MySpecialObject['name'],
|
||||
MySpecialObject['value'],
|
||||
MySpecialObject['more'],
|
||||
];
|
||||
expect(first[0]).toEqual(100);
|
||||
expect(first[1]).toEqual('a');
|
||||
expect(first[2]).toEqual(1);
|
||||
@@ -84,7 +89,10 @@ describe('dataFrameView', () => {
|
||||
});
|
||||
|
||||
it('Can handle fields with number name', () => {
|
||||
const view = new DataFrameView<MySpecialObject>(
|
||||
const view = new DataFrameView<{
|
||||
'1': string;
|
||||
'2': string;
|
||||
}>(
|
||||
new MutableDataFrame({
|
||||
fields: [
|
||||
{ name: '1', type: FieldType.string, values: ['a'] },
|
||||
@@ -93,7 +101,7 @@ describe('dataFrameView', () => {
|
||||
})
|
||||
);
|
||||
|
||||
const obj = view.get(0) as any;
|
||||
const obj = view.get(0);
|
||||
expect(obj['1']).toEqual('a');
|
||||
expect(obj['2']).toEqual('b');
|
||||
});
|
||||
|
||||
@@ -162,7 +162,7 @@ export class MutableDataFrame<T = any> extends FunctionalVector<T> implements Da
|
||||
return parser;
|
||||
}
|
||||
|
||||
private parseValue(field: Field, v: any): any {
|
||||
private parseValue(field: Field, v: string) {
|
||||
let p = this.parsers?.get(field);
|
||||
if (!p) {
|
||||
p = this.setParser(field, makeFieldParser(v, field));
|
||||
|
||||
@@ -123,7 +123,7 @@ export class StreamingDataFrame implements DataFrame {
|
||||
|
||||
dataFrameDTO.fields = dataFrameDTO.fields.map((f) => ({
|
||||
...f,
|
||||
values: (f.values as unknown[]).slice(numberOfItemsToRemove),
|
||||
values: f.values?.slice(numberOfItemsToRemove),
|
||||
}));
|
||||
|
||||
const length = dataFrameDTO.fields[0]?.values?.length ?? 0;
|
||||
|
||||
Reference in New Issue
Block a user