Chore: Stricter typing in type guards (#77809)

* Stricter typing in type guards

* create utility isObject fn

* better isAlertStateWithReason

* better name

* restore "data !== undefined"
This commit is contained in:
Josh Hunt
2023-11-13 16:11:54 +00:00
committed by GitHub
parent 3509a5abb9
commit 4a3c148298
9 changed files with 151 additions and 69 deletions
+32 -44
View File
@@ -515,39 +515,38 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "58"],
[0, 0, 0, "Unexpected any. Specify a different type.", "59"],
[0, 0, 0, "Unexpected any. Specify a different type.", "60"],
[0, 0, 0, "Unexpected any. Specify a different type.", "61"],
[0, 0, 0, "Do not use any type assertions.", "62"],
[0, 0, 0, "Unexpected any. Specify a different type.", "63"],
[0, 0, 0, "Do not use any type assertions.", "64"],
[0, 0, 0, "Unexpected any. Specify a different type.", "65"],
[0, 0, 0, "Do not use any type assertions.", "66"],
[0, 0, 0, "Unexpected any. Specify a different type.", "67"],
[0, 0, 0, "Do not use any type assertions.", "68"],
[0, 0, 0, "Unexpected any. Specify a different type.", "69"],
[0, 0, 0, "Do not use any type assertions.", "70"],
[0, 0, 0, "Unexpected any. Specify a different type.", "71"],
[0, 0, 0, "Do not use any type assertions.", "72"],
[0, 0, 0, "Unexpected any. Specify a different type.", "73"],
[0, 0, 0, "Do not use any type assertions.", "74"],
[0, 0, 0, "Do not use any type assertions.", "61"],
[0, 0, 0, "Unexpected any. Specify a different type.", "62"],
[0, 0, 0, "Do not use any type assertions.", "63"],
[0, 0, 0, "Unexpected any. Specify a different type.", "64"],
[0, 0, 0, "Do not use any type assertions.", "65"],
[0, 0, 0, "Unexpected any. Specify a different type.", "66"],
[0, 0, 0, "Do not use any type assertions.", "67"],
[0, 0, 0, "Unexpected any. Specify a different type.", "68"],
[0, 0, 0, "Do not use any type assertions.", "69"],
[0, 0, 0, "Unexpected any. Specify a different type.", "70"],
[0, 0, 0, "Do not use any type assertions.", "71"],
[0, 0, 0, "Unexpected any. Specify a different type.", "72"],
[0, 0, 0, "Do not use any type assertions.", "73"],
[0, 0, 0, "Unexpected any. Specify a different type.", "74"],
[0, 0, 0, "Unexpected any. Specify a different type.", "75"],
[0, 0, 0, "Unexpected any. Specify a different type.", "76"],
[0, 0, 0, "Do not use any type assertions.", "77"],
[0, 0, 0, "Do not use any type assertions.", "76"],
[0, 0, 0, "Unexpected any. Specify a different type.", "77"],
[0, 0, 0, "Unexpected any. Specify a different type.", "78"],
[0, 0, 0, "Unexpected any. Specify a different type.", "79"],
[0, 0, 0, "Do not use any type assertions.", "80"],
[0, 0, 0, "Do not use any type assertions.", "79"],
[0, 0, 0, "Unexpected any. Specify a different type.", "80"],
[0, 0, 0, "Unexpected any. Specify a different type.", "81"],
[0, 0, 0, "Unexpected any. Specify a different type.", "82"],
[0, 0, 0, "Do not use any type assertions.", "83"],
[0, 0, 0, "Do not use any type assertions.", "82"],
[0, 0, 0, "Unexpected any. Specify a different type.", "83"],
[0, 0, 0, "Unexpected any. Specify a different type.", "84"],
[0, 0, 0, "Unexpected any. Specify a different type.", "85"],
[0, 0, 0, "Do not use any type assertions.", "86"],
[0, 0, 0, "Do not use any type assertions.", "85"],
[0, 0, 0, "Unexpected any. Specify a different type.", "86"],
[0, 0, 0, "Unexpected any. Specify a different type.", "87"],
[0, 0, 0, "Unexpected any. Specify a different type.", "88"],
[0, 0, 0, "Do not use any type assertions.", "89"],
[0, 0, 0, "Do not use any type assertions.", "88"],
[0, 0, 0, "Unexpected any. Specify a different type.", "89"],
[0, 0, 0, "Unexpected any. Specify a different type.", "90"],
[0, 0, 0, "Unexpected any. Specify a different type.", "91"],
[0, 0, 0, "Do not use any type assertions.", "92"],
[0, 0, 0, "Unexpected any. Specify a different type.", "93"]
[0, 0, 0, "Do not use any type assertions.", "91"],
[0, 0, 0, "Unexpected any. Specify a different type.", "92"]
],
"packages/grafana-data/src/utils/Registry.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@@ -1847,14 +1846,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Styles should be written using objects.", "4"],
[0, 0, 0, "Styles should be written using objects.", "5"]
],
"public/app/features/alerting/unified/api/alertmanager.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/features/alerting/unified/api/ruler.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
],
"public/app/features/alerting/unified/components/AlertLabel.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"]
],
@@ -2968,12 +2959,11 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Do not use any type assertions.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Do not use any type assertions.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Do not use any type assertions.", "7"],
[0, 0, 0, "Do not use any type assertions.", "8"],
[0, 0, 0, "Do not use any type assertions.", "9"],
[0, 0, 0, "Unexpected any. Specify a different type.", "10"]
[0, 0, 0, "Unexpected any. Specify a different type.", "9"]
],
"public/app/features/dashboard/components/DashNav/DashNavButton.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"]
@@ -5405,8 +5395,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "3"],
[0, 0, 0, "Do not use any type assertions.", "4"],
[0, 0, 0, "Do not use any type assertions.", "5"],
[0, 0, 0, "Do not use any type assertions.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"]
[0, 0, 0, "Do not use any type assertions.", "6"]
],
"public/app/features/variables/state/keyedVariablesReducer.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@@ -7438,8 +7427,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "1"]
],
"public/app/types/unified-alerting-dto.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/test/core/redux/reduxTester.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],