Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit 3fe28fa

Browse files
authored
Merge pull request #1456 from ghiscoding/bugfix/settimeout-types
fix: use setTimeout/setInterval from window object with correct TS type
2 parents 7e39922 + 9b8278b commit 3fe28fa

22 files changed

+111
-111
lines changed

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@
5050
},
5151
"dependencies": {
5252
"@ngx-translate/core": "^15.0.0",
53-
"@slickgrid-universal/common": "~5.5.1",
54-
"@slickgrid-universal/custom-footer-component": "~5.5.1",
55-
"@slickgrid-universal/empty-warning-component": "~5.5.1",
56-
"@slickgrid-universal/event-pub-sub": "~5.5.1",
57-
"@slickgrid-universal/pagination-component": "~5.5.1",
58-
"@slickgrid-universal/row-detail-view-plugin": "~5.5.1",
59-
"@slickgrid-universal/rxjs-observable": "~5.5.1",
53+
"@slickgrid-universal/common": "~5.5.2",
54+
"@slickgrid-universal/custom-footer-component": "~5.5.2",
55+
"@slickgrid-universal/empty-warning-component": "~5.5.2",
56+
"@slickgrid-universal/event-pub-sub": "~5.5.2",
57+
"@slickgrid-universal/pagination-component": "~5.5.2",
58+
"@slickgrid-universal/row-detail-view-plugin": "~5.5.2",
59+
"@slickgrid-universal/rxjs-observable": "~5.5.2",
6060
"dequal": "^2.0.3",
6161
"rxjs": "^7.8.1"
6262
},
@@ -86,12 +86,12 @@
8686
"@ngx-translate/http-loader": "^8.0.0",
8787
"@popperjs/core": "^2.11.8",
8888
"@release-it/conventional-changelog": "^8.0.1",
89-
"@slickgrid-universal/composite-editor-component": "~5.5.1",
90-
"@slickgrid-universal/custom-tooltip-plugin": "~5.5.1",
91-
"@slickgrid-universal/excel-export": "~5.5.1",
92-
"@slickgrid-universal/graphql": "~5.5.1",
93-
"@slickgrid-universal/odata": "~5.5.1",
94-
"@slickgrid-universal/text-export": "~5.5.1",
89+
"@slickgrid-universal/composite-editor-component": "~5.5.2",
90+
"@slickgrid-universal/custom-tooltip-plugin": "~5.5.2",
91+
"@slickgrid-universal/excel-export": "~5.5.2",
92+
"@slickgrid-universal/graphql": "~5.5.2",
93+
"@slickgrid-universal/odata": "~5.5.2",
94+
"@slickgrid-universal/text-export": "~5.5.2",
9595
"@types/dompurify": "^3.0.5",
9696
"@types/fnando__sparkline": "^0.3.7",
9797
"@types/jest": "^29.5.12",

src/app/examples/custom-inputEditor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export class CustomInputEditor implements Editor {
5858
this.inputElm.addEventListener('focusout', this.save.bind(this));
5959
}
6060

61-
setTimeout(() => {
61+
window.setTimeout(() => {
6262
this.inputElm.focus();
6363
this.inputElm.select();
6464
}, 50);

src/app/examples/grid-base-row-editing.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ export class GridBaseRowEditingComponent implements OnInit {
257257

258258
function fakeFetch(_input: string | URL | Request, _init?: RequestInit | undefined): Promise<Response> {
259259
return new Promise((resolve) => {
260-
setTimeout(() => {
260+
window.setTimeout(() => {
261261
resolve(new Response(JSON.stringify({ status: 200, message: 'success' })));
262262
// reduces the delay for automated Cypress tests
263263
}, (window as any).Cypress ? 10 : 500);

src/app/examples/grid-clientside.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ export class GridClientSideComponent implements OnInit {
271271

272272
refreshMetrics(e: Event, args: any) {
273273
if (args && args.current >= 0) {
274-
setTimeout(() => {
274+
window.setTimeout(() => {
275275
this.metrics = {
276276
startTime: new Date(),
277277
endTime: new Date(),

src/app/examples/grid-composite-editor.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ export class GridCompositeEditorComponent implements OnDestroy, OnInit {
650650
// when processing a mass update or mass selection
651651
if (modalType === 'mass-update' || modalType === 'mass-selection') {
652652
return new Promise((resolve, reject) => {
653-
setTimeout(() => {
653+
window.setTimeout(() => {
654654
if (formValues.percentComplete >= 50) {
655655
resolve(true);
656656
} else {
@@ -663,7 +663,7 @@ export class GridCompositeEditorComponent implements OnDestroy, OnInit {
663663
// we'll just apply the change without any rejection from the server and
664664
// note that we also have access to the "dataContext" which is only available for these modal
665665
console.log(`${modalType} item data context`, dataContext);
666-
return new Promise(resolve => setTimeout(() => resolve(true), serverResponseDelay));
666+
return new Promise(resolve => window.setTimeout(() => resolve(true), serverResponseDelay));
667667
}
668668
}
669669
});

src/app/examples/grid-custom-tooltip.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class GridCustomTooltipComponent implements OnInit {
7676
// you will need to provide an `asyncPost` function returning a Promise and also `asyncPostFormatter` formatter to display the result once the Promise resolves
7777
formatter: () => `<div><span class="mdi mdi-load mdi-spin-1s"></span> loading...</div>`,
7878
asyncProcess: () => new Promise(resolve => {
79-
setTimeout(() => resolve({ ratio: Math.random() * 10 / 10, lifespan: Math.random() * 100 }), this.serverApiDelay);
79+
window.setTimeout(() => resolve({ ratio: Math.random() * 10 / 10, lifespan: Math.random() * 100 }), this.serverApiDelay);
8080
}),
8181
asyncPostFormatter: this.tooltipTaskAsyncFormatter as Formatter,
8282

@@ -180,7 +180,7 @@ export class GridCustomTooltipComponent implements OnInit {
180180

181181
// 2- delay the opening by a simple Promise and `setTimeout`
182182
asyncProcess: () => new Promise(resolve => {
183-
setTimeout(() => resolve({}), this.serverApiDelay); // delayed by half a second
183+
window.setTimeout(() => resolve({}), this.serverApiDelay); // delayed by half a second
184184
}),
185185
asyncPostFormatter: this.tooltipFormatter.bind(this) as Formatter,
186186
},
@@ -235,7 +235,7 @@ export class GridCustomTooltipComponent implements OnInit {
235235

236236
// OR 2- use a Promise
237237
collectionAsync: new Promise<any>((resolve) => {
238-
setTimeout(() => {
238+
window.setTimeout(() => {
239239
resolve(Array.from(Array(this.dataset.length).keys()).map(k => ({ value: k, label: k, prefix: 'Task', suffix: 'days' })));
240240
}, 500);
241241
}),
@@ -252,7 +252,7 @@ export class GridCustomTooltipComponent implements OnInit {
252252
filter: {
253253
// collectionAsync: fetch(URL_SAMPLE_COLLECTION_DATA),
254254
collectionAsync: new Promise((resolve) => {
255-
setTimeout(() => {
255+
window.setTimeout(() => {
256256
resolve(Array.from(Array(this.dataset.length).keys()).map(k => ({ value: k, label: `Task ${k}` })));
257257
});
258258
}),

src/app/examples/grid-editor.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ export class GridEditorComponent implements OnInit {
500500
const newRows = this.mockData(1, lastRowIndex);
501501

502502
// wrap into a timer to simulate a backend async call
503-
setTimeout(() => {
503+
window.setTimeout(() => {
504504
const requisiteColumnDef = this.columnDefinitions.find((column: Column) => column.id === 'prerequisites');
505505
if (requisiteColumnDef) {
506506
const filterCollectionAsync = requisiteColumnDef.filter!.collectionAsync;

src/app/examples/grid-formatter.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export class GridFormatterComponent implements OnInit {
155155
item.completed = !item.completed;
156156

157157
// simulate a backend http call and refresh the grid row after delay
158-
setTimeout(() => {
158+
window.setTimeout(() => {
159159
this.angularGrid.gridService.updateItemById(item.id, item, { highlightRow: false });
160160
}, 250);
161161
}

src/app/examples/grid-graphql.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ export class GridGraphqlComponent implements OnInit, OnDestroy {
307307
};
308308

309309
return new Promise(resolve => {
310-
setTimeout(() => {
310+
window.setTimeout(() => {
311311
this.graphqlQuery = this.angularGrid.backendService!.buildQuery();
312312
if (this.isWithCursor) {
313313
// When using cursor pagination, the pagination service needs to be updated with the PageInfo data from the latest request
@@ -388,7 +388,7 @@ export class GridGraphqlComponent implements OnInit, OnDestroy {
388388
{ columnId: 'name', direction: 'asc' },
389389
{ columnId: 'company', direction: SortDirection.DESC }
390390
]);
391-
setTimeout(() => {
391+
window.setTimeout(() => {
392392
this.angularGrid.paginationService?.changeItemPerPage(20);
393393
this.angularGrid.paginationService?.goToPageNumber(2);
394394
});

src/app/examples/grid-infinite-graphql.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ export class GridInfiniteGraphqlComponent implements OnInit, OnDestroy {
311311
},
312312
};
313313

314-
setTimeout(() => {
314+
window.setTimeout(() => {
315315
this.graphqlQuery = this.gridOptions.backendServiceApi!.service.buildQuery();
316316
resolve(mockedResult);
317317
}, this.serverWaitDelay);

0 commit comments

Comments
 (0)