Skip to content

Commit 4190423

Browse files
committed
chore: update tsconfig
1 parent 2356f55 commit 4190423

File tree

6 files changed

+20
-26
lines changed

6 files changed

+20
-26
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"@storybook/addon-links": "^9.0.8",
3939
"@storybook/react-vite": "^9.0.8",
4040
"@types/react": "^18.3.11",
41+
"@zakodium/tsconfig": "^1.0.1",
4142
"eslint": "^9.28.0",
4243
"eslint-config-zakodium": "^15.0.1",
4344
"eslint-plugin-storybook": "^9.0.8",

src/hooks/useBBoxObserver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function useBBoxObserver<ElementType extends SVGGraphicsElement>() {
2020
}
2121
if (element !== null) {
2222
const observer = new ResizeObserver(([entry]) => {
23-
const bbox = (entry.target as ElementType).getBBox();
23+
const bbox = (entry?.target as ElementType).getBBox();
2424
const previous = previousSize.current;
2525
if (
2626
previous.x !== bbox.x ||

src/hooks/useLogTicks.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ function formatTicks(
3232
minSpace: number,
3333
): PrimaryLogTicks[] {
3434
const scaledTicks = ticks.filter((val) => isMainTick(val) === 1).map(scale);
35-
const mainTickSpace = Math.abs(scaledTicks[0] - scaledTicks[1]);
35+
const mainTickSpace = Math.abs(
36+
// TODO: `scaledTicks` might not have a length >1
37+
(scaledTicks[0] as number) - (scaledTicks[1] as number),
38+
);
3639
const mainTickRatio = (maxWordSpace + minSpace) / mainTickSpace;
3740
const mainTicksStep = mainTickRatio >= 1 ? Math.ceil(mainTickRatio) : 1;
3841

src/hooks/useTicks.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ export function useTicks<T extends number | Date>(
4343
ref: MutableRefObject<SVGGElement | null>,
4444
options: Options<T>,
4545
) {
46-
const range = scale.range();
47-
if (!range) throw new Error('Range needs to be specified');
46+
const range = scale.range() as [number, number];
47+
if (!range || range.length !== 2) {
48+
throw new Error('Range needs to be specified');
49+
}
4850

4951
const domain = scale.domain();
5052
if (!domain) throw new Error('Domain needs to be specified');

stories/hooks/advanced_ticks.stories.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ export default {
1010
title: 'Hooks/Advanced Ticks',
1111
} as Meta;
1212

13-
const LARGE_RANGE = [0, 600];
14-
const SMALL_RANGE = [0, 40];
15-
const DOMAIN_LARGE = [0, 100];
16-
const DOMAIN_SMALL = [50, 50.0001];
13+
type Domain = [number, number];
14+
15+
const LARGE_RANGE: Domain = [0, 600];
16+
const SMALL_RANGE: Domain = [0, 40];
17+
const DOMAIN_LARGE: Domain = [0, 100];
18+
const DOMAIN_SMALL: Domain = [50, 50.0001];
1719

1820
export function AdvancedCustomTicks() {
1921
const ref = useRef<SVGGElement>(null);
@@ -65,7 +67,7 @@ function computeLinearTicks(
6567
secondaryTickSize?: number;
6668
} = {},
6769
): AxisTick[] {
68-
const viewport = xAccessor.domain();
70+
const viewport = xAccessor.domain() as Domain;
6971
const ticks: AxisTick[] = [];
7072
const {
7173
noSecondaryTicks = false,
@@ -113,7 +115,7 @@ function computeLinearTicks(
113115
ticks.push({
114116
value,
115117
position: xAccessor(value),
116-
label: primaryTicks[primaryTickIndex]?.label ?? null,
118+
label: primaryTicks[primaryTickIndex]?.label ?? '',
117119
size: n % nSubTicks === 0 ? primaryTickSize : secondaryTickSize,
118120
});
119121
}

tsconfig.json

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
11
{
2+
"extends": "@zakodium/tsconfig/jsx",
23
"compilerOptions": {
3-
"lib": ["DOM", "ES2022"],
4-
"types": [],
5-
"target": "ES2022",
6-
"outDir": "lib",
7-
"jsx": "react-jsx",
8-
"module": "NodeNext",
9-
"strict": true,
10-
"skipLibCheck": true,
11-
"resolveJsonModule": false,
12-
"forceConsistentCasingInFileNames": true,
13-
"allowJs": false,
14-
"isolatedModules": true,
15-
"verbatimModuleSyntax": true,
16-
"sourceMap": true,
17-
"declaration": true,
18-
"declarationMap": true
4+
"outDir": "lib"
195
},
206
"include": ["src", "stories"]
217
}

0 commit comments

Comments
 (0)