Skip to content

Commit 1138896

Browse files
authored
🤖 Merge PR DefinitelyTyped#71958 [Chrome] set noImplicitAny to true in tsconfig by @erwanjugand
1 parent dc8bfc3 commit 1138896

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

‎types/chrome/test/index.ts‎

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,29 @@ function bookmarksExample() {
1010
});
1111
});
1212
// Traverse the bookmark tree, and print the folder and nodes.
13-
function dumpBookmarks(query?) {
13+
function dumpBookmarks(query?: string | string[] | number) {
1414
var bookmarkTreeNodes = chrome.bookmarks.getTree(function(bookmarkTreeNodes) {
1515
$("#bookmarks").append(dumpTreeNodes(bookmarkTreeNodes, query));
1616
});
1717
}
18-
function dumpTreeNodes(bookmarkNodes, query) {
18+
function dumpTreeNodes(bookmarkNodes: chrome.bookmarks.BookmarkTreeNode[], query?: string | string[] | number) {
1919
var list = $("<ul>");
2020
var i;
2121
for (i = 0; i < bookmarkNodes.length; i++) {
2222
list.append(dumpNode(bookmarkNodes[i], query));
2323
}
2424
return list;
2525
}
26-
function dumpNode(bookmarkNode, query) {
26+
function dumpNode(bookmarkNode: chrome.bookmarks.BookmarkTreeNode, query?: string | string[] | number) {
2727
var span = $("<span>");
2828
if (bookmarkNode.title) {
29-
if (query && !bookmarkNode.children) {
29+
if (query && typeof query === "string" && !bookmarkNode.children) {
3030
if (String(bookmarkNode.title).indexOf(query) == -1) {
3131
return $("<span></span>");
3232
}
3333
}
3434
var anchor = $("<a>");
35-
anchor.attr("href", bookmarkNode.url);
35+
anchor.attr("href", bookmarkNode.url ?? null);
3636
anchor.text(bookmarkNode.title);
3737
/*
3838
* When clicking on a bookmark in the extension, a new tab is fired with
@@ -291,8 +291,8 @@ function testNotificationCreation() {
291291

292292
// https://developer.chrome.com/extensions/examples/api/contentSettings/popup.js
293293
function contentSettings() {
294-
var incognito;
295-
var url;
294+
var incognito: boolean;
295+
var url: string;
296296

297297
function settingChanged() {
298298
// @ts-expect-error Need refactor this without using `this`
@@ -304,6 +304,7 @@ function contentSettings() {
304304
// HACK: [type] is not recognised by the docserver's sample crawler, so
305305
// mention an explicit
306306
// type: chrome.contentSettings.cookies.set - See http://crbug.com/299634
307+
// @ts-expect-error Need refactor tests to use the correct type
307308
chrome.contentSettings[type].set({
308309
primaryPattern: pattern,
309310
setting: setting,
@@ -315,7 +316,7 @@ function contentSettings() {
315316
chrome.tabs.query({ active: true, currentWindow: true, url: ["http://*/*", "https://*/*"] }, function(tabs) {
316317
var current = tabs[0];
317318
incognito = current.incognito;
318-
url = current.url;
319+
url = current.url ?? "";
319320
var types = [
320321
"cookies",
321322
"images",
@@ -335,18 +336,19 @@ function contentSettings() {
335336
// HACK: [type] is not recognised by the docserver's sample crawler, so
336337
// mention an explicit
337338
// type: chrome.contentSettings.cookies.get - See http://crbug.com/299634
338-
chrome.contentSettings[type]
339-
&& chrome.contentSettings[type].get(
340-
{
341-
primaryUrl: url,
342-
incognito: incognito,
343-
},
344-
function(details) {
345-
var input = <HTMLInputElement> document.getElementById(type);
346-
input.disabled = false;
347-
input.value = details.setting;
348-
},
349-
);
339+
// @ts-expect-error Need refactor tests to use the correct type
340+
chrome.contentSettings[type] && chrome.contentSettings[type].get(
341+
{
342+
primaryUrl: url,
343+
incognito: incognito,
344+
},
345+
// @ts-expect-error
346+
function(details) {
347+
var input = <HTMLInputElement> document.getElementById(type);
348+
input.disabled = false;
349+
input.value = details.setting;
350+
},
351+
);
350352
});
351353
});
352354

@@ -728,7 +730,7 @@ function testStorage() {
728730
chrome.storage.sync.get(null, (data) => {
729731
console.log(data.myKey);
730732
});
731-
chrome.storage.sync.get((data) => {
733+
chrome.storage.sync.get((data: any) => {
732734
console.log(data.badKey);
733735
});
734736

‎types/chrome/tsconfig.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"es6",
66
"dom"
77
],
8-
"noImplicitAny": false,
8+
"noImplicitAny": true,
99
"noImplicitThis": true,
1010
"strictNullChecks": true,
1111
"strictFunctionTypes": true,

0 commit comments

Comments
 (0)