Correct type for to-budget field (#3237)

* Correct type for `to-budget` field

* Add release notes

* Don't enable `strictNullChecks` for now
This commit is contained in:
Julian Dominguez-Schatz
2024-08-11 16:52:35 -04:00
committed by GitHub
parent 8142dd1ec9
commit d1362c3d74
4 changed files with 21 additions and 28 deletions

View File

@@ -36,7 +36,7 @@ export function ToBudget({
value: 0,
});
const availableValue = sheetValue;
if (typeof availableValue !== 'number') {
if (typeof availableValue !== 'number' && availableValue !== null) {
throw new Error(
'Expected availableValue to be a number but got ' + availableValue,
);
@@ -83,7 +83,7 @@ export function ToBudget({
)}
{menuOpen === 'transfer' && (
<TransferMenu
initialAmount={availableValue}
initialAmount={availableValue ?? undefined}
onClose={() => setMenuOpen(null)}
onSubmit={(amount, categoryId) => {
onBudgetAction(month, 'transfer-available', {

View File

@@ -39,12 +39,12 @@ export function ToBudgetAmount({
});
const format = useFormat();
const availableValue = sheetValue;
if (typeof availableValue !== 'number') {
if (typeof availableValue !== 'number' && availableValue !== null) {
throw new Error(
'Expected availableValue to be a number but got ' + availableValue,
);
}
const num = isNaN(availableValue) ? 0 : availableValue;
const num = availableValue ?? 0;
const isNegative = num < 0;
return (

View File

@@ -7,11 +7,7 @@
"compilerOptions": {
// "composite": true,
"target": "ES2022",
"lib": [
"ES2022",
"DOM",
"DOM.Iterable"
],
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"experimentalDecorators": true,
@@ -23,10 +19,7 @@
"noFallthroughCasesInSwitch": true,
"skipLibCheck": true,
"jsx": "preserve",
"types": [
"vite/client",
"jest"
],
"types": ["vite/client", "jest"],
// Check JS files too
"allowJs": true,
"checkJs": false,
@@ -38,33 +31,27 @@
"noEmit": true,
"paths": {
// until we turn on composite/references
"loot-core/*": [
"./packages/loot-core/src/*"
],
"loot-core/*": ["./packages/loot-core/src/*"],
},
"plugins": [
{
"name": "typescript-strict-plugin",
"path": [
"./packages"
]
}
]
"path": ["./packages"],
},
],
},
"include": [
"packages/**/*"
],
"include": ["packages/**/*"],
"exclude": [
"node_modules",
"**/node_modules/*",
"**/build/*",
"**/client-build/*",
"**/dist/*",
"**/lib-dist/*"
"**/lib-dist/*",
],
"ts-node": {
"compilerOptions": {
"module": "CommonJS"
}
}
"module": "CommonJS",
},
},
}

View File

@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [jfdoming]
---
Fix crash when visiting later months