Skip to content

Commit 7823ddb

Browse files
HazATlynnagara
authored andcommitted
feat(typescript): Add TypeScript compatibility (#13786)
Updates tsconfig with allowJs: false and noImplicityAny: false. This prevents the TypeScript engine from processing *.jsx files and makes it easier to import jsx files in TypeScript code. Once we have migrated more code to *.tsx we should look into turning `noImplicitAny` back to true. This migrates the following code to TypeScript - All Discover functionality - Some utility functions
1 parent 53e3360 commit 7823ddb

39 files changed

+958
-655
lines changed

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@
2222
"@sentry/integrations": "^5.4.2",
2323
"@sentry/typescript": "^5.3.0",
2424
"@types/lodash": "^4.14.134",
25-
"@types/react-dom": "^16.8.4",
25+
"@types/moment-timezone": "^0.5.12",
26+
"@types/papaparse": "^4.5.11",
27+
"@types/react": "^16.7.0",
28+
"@types/react-bootstrap": "^0.32.19",
29+
"@types/react-document-title": "^2.0.3",
30+
"@types/react-dom": "^16.7.0",
31+
"@types/react-router": "^3.0.20",
32+
"@types/react-virtualized": "^9.20.1",
2633
"algoliasearch": "^3.32.0",
2734
"babel-core": "^7.0.0-bridge.0",
2835
"babel-loader": "^8.0.0",

src/sentry/static/sentry/app/styles/space.jsx renamed to src/sentry/static/sentry/app/styles/space.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const space = size => {
1+
const space = (size: number): string => {
22
switch (size) {
33
//Our spacing scale is based on a base unit of 8
44
//We use a case switch to prevent odd numbers, decimals, and big numbers.

src/sentry/static/sentry/app/utils/theme.jsx renamed to src/sentry/static/sentry/app/utils/theme.tsx

Lines changed: 124 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import CHART_PALETTE from 'app/constants/chartPalette';
22

3-
const theme = {
4-
breakpoints: ['768px', '992px', '1200px'],
5-
3+
const colors = {
64
// Colors
75
offWhite: '#FAF9FB',
86
offWhite2: '#E7E1EC',
@@ -71,6 +69,107 @@ const theme = {
7169

7270
background: '#fff',
7371
placeholderBackground: '#f5f5f5',
72+
};
73+
74+
const warning = {
75+
backgroundLight: colors.yellowLightest,
76+
background: colors.yellowDarkest,
77+
border: colors.yellowDark,
78+
iconColor: colors.yellowDark,
79+
};
80+
81+
const alert = {
82+
muted: {
83+
backgroundLight: colors.offWhite,
84+
background: colors.gray1,
85+
border: colors.gray6,
86+
},
87+
info: {
88+
backgroundLight: colors.blueLightest,
89+
border: colors.blueLight,
90+
iconColor: colors.blue,
91+
background: colors.blue,
92+
},
93+
warning,
94+
//alias warn to warning
95+
warn: warning,
96+
success: {
97+
backgroundLight: colors.greenLightest,
98+
border: colors.green,
99+
iconColor: colors.greenDark,
100+
background: colors.green,
101+
},
102+
error: {
103+
backgroundLight: colors.redLightest,
104+
border: colors.redLight,
105+
textLight: colors.redLight,
106+
iconColor: colors.red,
107+
background: colors.red,
108+
},
109+
beta: {
110+
background: `linear-gradient(90deg, ${colors.pink}, ${colors.purple})`,
111+
},
112+
};
113+
114+
const aliases = {
115+
textColor: colors.gray5,
116+
success: colors.green,
117+
error: colors.red,
118+
disabled: colors.gray1,
119+
};
120+
121+
const button = {
122+
borderRadius: '3px',
123+
124+
default: {
125+
color: '#2f2936',
126+
colorActive: '#161319',
127+
background: colors.white,
128+
backgroundActive: colors.white,
129+
border: '#d8d2de',
130+
borderActive: '#c9c0d1',
131+
},
132+
primary: {
133+
color: colors.white,
134+
background: colors.purple,
135+
backgroundActive: '#4e3fb4',
136+
border: '#3d328e',
137+
borderActive: '#352b7b',
138+
},
139+
success: {
140+
color: colors.white,
141+
background: '#3fa372',
142+
backgroundActive: colors.green,
143+
border: '#7ccca5',
144+
borderActive: '#7ccca5',
145+
},
146+
danger: {
147+
color: colors.white,
148+
background: colors.red,
149+
backgroundActive: '#bf2a1d',
150+
border: '#bf2a1d',
151+
borderActive: '#7d1c13',
152+
},
153+
link: {
154+
color: colors.blue,
155+
background: 'transparent',
156+
// border: '#3d328e',
157+
backgroundActive: 'transparent',
158+
// borderActive: '#352b7b',
159+
},
160+
disabled: {
161+
color: aliases.disabled,
162+
border: '#e3e5e6',
163+
borderActive: '#e3e5e6',
164+
background: colors.white,
165+
backgroundActive: colors.white,
166+
},
167+
};
168+
169+
const theme = {
170+
breakpoints: ['768px', '992px', '1200px'],
171+
172+
...colors,
74173

75174
// Try to keep these ordered plz
76175
zIndex: {
@@ -142,123 +241,36 @@ const theme = {
142241
lineHeightHeading: '1.15',
143242
lineHeightBody: '1.4',
144243
},
145-
};
146244

147-
// Aliases
148-
theme.textColor = theme.gray5;
149-
theme.success = theme.green;
150-
theme.error = theme.red;
151-
theme.disabled = theme.gray1;
245+
// Aliases
246+
...aliases,
152247

153-
theme.alert = {
154-
muted: {
155-
backgroundLight: theme.offWhite,
156-
background: theme.gray1,
157-
border: theme.gray6,
158-
},
159-
info: {
160-
backgroundLight: theme.blueLightest,
161-
border: theme.blueLight,
162-
iconColor: theme.blue,
163-
background: theme.blue,
164-
},
165-
warning: {
166-
backgroundLight: theme.yellowLightest,
167-
background: theme.yellowDarkest,
168-
border: theme.yellowDark,
169-
iconColor: theme.yellowDark,
170-
},
171-
success: {
172-
backgroundLight: theme.greenLightest,
173-
border: theme.green,
174-
iconColor: theme.greenDark,
175-
background: theme.green,
176-
},
177-
error: {
178-
backgroundLight: theme.redLightest,
179-
border: theme.redLight,
180-
textLight: theme.redLight,
181-
iconColor: theme.red,
182-
background: theme.red,
183-
},
184-
beta: {
185-
background: `linear-gradient(90deg, ${theme.pink}, ${theme.purple})`,
186-
},
187-
};
248+
alert,
249+
button,
188250

189-
//alias warn to warning
190-
theme.alert.warn = theme.alert.warning;
251+
charts: {
252+
colors: CHART_PALETTE[CHART_PALETTE.length - 1],
191253

192-
theme.button = {
193-
borderRadius: '3px',
254+
// We have an array that maps `number + 1` --> list of `number` colors
255+
getColorPalette: (length: number) =>
256+
CHART_PALETTE[Math.min(CHART_PALETTE.length - 1, length + 1)],
194257

195-
default: {
196-
color: '#2f2936',
197-
colorActive: '#161319',
198-
background: theme.white,
199-
backgroundActive: theme.white,
200-
border: '#d8d2de',
201-
borderActive: '#c9c0d1',
258+
previousPeriod: colors.gray1,
259+
symbolSize: 6,
202260
},
203-
primary: {
204-
color: theme.white,
205-
background: theme.purple,
206-
backgroundActive: '#4e3fb4',
207-
border: '#3d328e',
208-
borderActive: '#352b7b',
209-
},
210-
success: {
211-
color: theme.white,
212-
background: '#3fa372',
213-
backgroundActive: theme.green,
214-
border: '#7ccca5',
215-
borderActive: '#7ccca5',
216-
},
217-
danger: {
218-
color: theme.white,
219-
background: theme.red,
220-
backgroundActive: '#bf2a1d',
221-
border: '#bf2a1d',
222-
borderActive: '#7d1c13',
223-
},
224-
link: {
225-
color: theme.blue,
226-
background: 'transparent',
227-
// border: '#3d328e',
228-
backgroundActive: 'transparent',
229-
// borderActive: '#352b7b',
230-
},
231-
disabled: {
232-
color: theme.disabled,
233-
border: '#e3e5e6',
234-
borderActive: '#e3e5e6',
235-
background: theme.white,
236-
backgroundActive: theme.white,
237-
},
238-
};
239-
240-
theme.charts = {
241-
colors: CHART_PALETTE[CHART_PALETTE.length - 1],
242261

243-
// We have an array that maps `number + 1` --> list of `number` colors
244-
getColorPalette: length =>
245-
CHART_PALETTE[Math.min(CHART_PALETTE.length - 1, length + 1)],
246-
247-
previousPeriod: theme.gray1,
248-
symbolSize: 6,
249-
};
250-
251-
theme.diff = {
252-
removedRow: '#fcefee',
253-
addedRow: '#f5fbf8',
254-
removed: '#f7ceca',
255-
added: '#d8f0e4',
256-
};
262+
diff: {
263+
removedRow: '#fcefee',
264+
addedRow: '#f5fbf8',
265+
removed: '#f7ceca',
266+
added: '#d8f0e4',
267+
},
257268

258-
// Similarity spectrum used in "Similar Issues" in group details
259-
theme.similarity = {
260-
empty: '#e2dee6',
261-
colors: ['#ec5e44', '#f38259', '#f9a66d', '#98b480', '#57be8c'],
269+
// Similarity spectrum used in "Similar Issues" in group details
270+
similarity: {
271+
empty: '#e2dee6',
272+
colors: ['#ec5e44', '#f38259', '#f9a66d', '#98b480', '#57be8c'],
273+
},
262274
};
263275

264276
export default theme;

0 commit comments

Comments
 (0)