Skip to content

Commit f446cca

Browse files
committed
refactor: enable noUncheckedIndexedAccess (#2006)
enables stricter types for array access. BREAKING CHANGE: Enables stricter type option in src and could have unexpected changes. This release is meant to serve as a clean break in case any issues arise.
1 parent b613189 commit f446cca

File tree

245 files changed

+1316
-1294
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

245 files changed

+1316
-1294
lines changed

.buildkite/utils/github.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ export const updateCheckStatus = async (
229229
// revert the completed check run is to create a new check run. This will not show as a duplicate run.
230230
const newCheckNeeded = options.status !== 'completed' && checkRun?.status === 'completed';
231231

232-
console.trace('updateCheckStatus', checkId, title);
233-
console.log(JSON.stringify(options, null, 2));
232+
// console.trace('updateCheckStatus', checkId, title);
233+
// console.log(JSON.stringify(options, null, 2));
234234

235235
try {
236236
const output =

e2e/page_objects/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export class CommonPage {
167167

168168
static validatePath(path: string | string[]): string | string[] {
169169
const fileName = Array.isArray(path) ? path[path.length - 1] : path;
170-
if (/\.png$/.test(fileName)) return path;
170+
if (fileName && /\.png$/.test(fileName)) return path;
171171
throw new Error(`Screenshot path or last path segment must contain the .png file extension.`);
172172
}
173173

e2e/tests/legend_stories.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ test.describe('Legend stories', () => {
208208
const getPositionalUrl = (p1: string, p2: string, others: string = '') =>
209209
`http://localhost:9001/?path=/story/legend--inside-chart&knob-vAlign_Legend=${p1}&knob-hAlign_Legend=${p2}${others}`;
210210

211-
pwEach.test([
211+
pwEach.test<[Position, Position]>([
212212
[Position.Top, Position.Left],
213213
[Position.Top, Position.Right],
214214
[Position.Bottom, Position.Left],
@@ -220,7 +220,7 @@ test.describe('Legend stories', () => {
220220
},
221221
);
222222

223-
pwEach.test([
223+
pwEach.test<[Position, Position]>([
224224
[Position.Top, Position.Left],
225225
[Position.Top, Position.Right],
226226
[Position.Bottom, Position.Left],
@@ -235,7 +235,7 @@ test.describe('Legend stories', () => {
235235
const longLabel =
236236
'Non do aliqua veniam dolore ipsum eu aliquip. Culpa in duis amet non velit qui non ullamco sit adipisicing. Ut sunt Lorem mollit exercitation deserunt officia sunt ipsum eu amet.';
237237

238-
pwEach.test([
238+
pwEach.test<[Position, Position]>([
239239
[Position.Top, Position.Left],
240240
[Position.Top, Position.Right],
241241
[Position.Bottom, Position.Left],

github_bot/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM node:16-alpine as builder
22
WORKDIR /app
33
COPY package.json yarn.lock ./
44
RUN yarn install --frozen-lockfile
5-
COPY tsconfig.json ./
5+
COPY tsconfig.main.json ./tsconfig.json
66
COPY src src
77
RUN yarn build
88

github_bot/src/github/events/push/trigger_build.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@ import { checkCommitFn, isBaseRepo, testPatternString, updateAllChecks } from '.
1616
* build trigger for pushes to select base branches not pull requests
1717
*/
1818
export function setupBuildTrigger(app: Probot) {
19+
// @ts-ignore - probot issue https://github.com/probot/probot/issues/1680
1920
app.on('push', async (ctx) => {
2021
const [branch] = ctx.payload.ref.split('/').reverse();
2122

22-
if (!isBaseRepo(ctx.payload.repository) || !getConfig().github.env.branch.base.some(testPatternString(branch))) {
23+
if (
24+
!branch ||
25+
!isBaseRepo(ctx.payload.repository) ||
26+
!getConfig().github.env.branch.base.some(testPatternString(branch))
27+
) {
2328
return;
2429
}
2530

github_bot/src/github/utils.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ export async function syncChecks(ctx: ProbotEventContext<'pull_request'>) {
259259

260260
const [previousCommitSha] = await getLatestCommits(ctx);
261261

262+
if (!previousCommitSha) throw new Error('Unable to load previous commit');
263+
262264
const {
263265
data: { check_runs: checks },
264266
} = await ctx.octokit.checks.listForRef({
@@ -348,14 +350,15 @@ export async function updatePreviousDeployments(
348350
await Promise.all(
349351
deployments.map(async ({ id }) => {
350352
const {
351-
data: [{ environment, state: currentState, ...status }],
353+
data: [data],
352354
} = await ctx.octokit.repos.listDeploymentStatuses({
353355
...ctx.repo(),
354356
deployment_id: id,
355357
per_page: 1,
356358
});
357359

358-
if (['in_progress', 'queued', 'pending'].includes(currentState)) {
360+
if (data && ['in_progress', 'queued', 'pending'].includes(data.state)) {
361+
const { environment, ...status } = data;
359362
await ctx.octokit.repos.createDeploymentStatus({
360363
...ctx.repo(),
361364
...status,
File renamed without changes.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@
5252
"test:e2e:generate:page": "./e2e_server/scripts/compile_vrt_page.sh",
5353
"test:e2e:server": "sh ./e2e_server/scripts/start.sh",
5454
"test:e2e:server:build": "cd e2e_server/server && webpack build",
55+
"typecheck:base": "tsc -p ./tsconfig.base.json --noEmit",
5556
"typecheck:src": "lerna run --loglevel=silent --scope @elastic/charts typecheck --stream --no-prefix",
56-
"typecheck:all": "tsc -p ./tsconfig.json --noEmit",
57+
"typecheck:storybook": "lerna run --loglevel=silent --scope charts-storybook typecheck --stream --no-prefix",
58+
"typecheck:all": "yarn typecheck:base && yarn typecheck:src && yarn typecheck:storybook",
5759
"ts:prune": "ts-prune"
5860
},
5961
"devDependencies": {

packages/charts/api-extractor.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
7979
* DEFAULT VALUE: "<projectFolder>/tsconfig.json"
8080
*/
81-
"tsconfigFilePath": "<projectFolder>/tsconfig.json",
81+
"tsconfigFilePath": "<projectFolder>/tsconfig.src.json",
8282
/**
8383
* Provides a compiler configuration that will be used instead of reading the tsconfig.json file from disk.
8484
* The object must conform to the TypeScript tsconfig schema:

packages/charts/api/charts.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2247,7 +2247,7 @@ export type Ratio = number;
22472247
export type RawTextGetter = (node: ShapeTreeNode) => string;
22482248

22492249
// @public (undocumented)
2250-
export const RectAnnotation: FC<SFProps<RectAnnotationSpec, "chartType" | "specType", "style" | "zIndex" | "groupId" | "outside" | "annotationType", "fallbackPlacements" | "placement" | "offset" | "boundary" | "boundaryPadding" | "customTooltip" | "customTooltipDetails" | "hideTooltips" | "animations" | "renderTooltip" | "outsideDimension", "id" | "dataValues">>;
2250+
export const RectAnnotation: FC<SFProps<RectAnnotationSpec, "chartType" | "specType", "style" | "zIndex" | "groupId" | "outside" | "annotationType", "fallbackPlacements" | "placement" | "offset" | "boundary" | "boundaryPadding" | "customTooltip" | "hideTooltips" | "customTooltipDetails" | "animations" | "renderTooltip" | "outsideDimension", "id" | "dataValues">>;
22512251

22522252
// @public
22532253
export interface RectAnnotationDatum {

0 commit comments

Comments
 (0)