Skip to content

Commit

Permalink
Merge pull request #9155 from hicommonwealth/tim/strict-null-check-fixes
Browse files Browse the repository at this point in the history
Fix remaining strict null check issues
  • Loading branch information
burtonator authored Sep 9, 2024
2 parents 83911c4 + b3d80ca commit 51f6f0c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 41 deletions.
56 changes: 28 additions & 28 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,34 +259,34 @@ jobs:
run: pnpm lint-branch


# detect-broken-ts-expect-error:
# name: Detect Broken TS expect errors
# runs-on: ubuntu-latest
# timeout-minutes: 10
# strategy:
# matrix:
# node: [ 20 ]
#
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0
# - uses: ./.github/actions/setup
# with:
# node-version: ${{ matrix.node }}
#
# - name: Assert pnpm-lock.yaml is correct
# run: |
# if ! git diff --quiet; then
# echo 'You need to update the pnpm-lock.yaml file (potentially after installing node-gyp)'
# exit 1
# fi
#
# - name: build
# run: pnpm -r build
#
# - name: run detect-broken-ts-expect-error.sh
# run: cd packages/commonwealth && ./scripts/detect-broken-ts-expect-error.sh
detect-broken-ts-expect-error:
name: Detect Broken TS expect errors
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
node: [ 20 ]

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}

- name: Assert pnpm-lock.yaml is correct
run: |
if ! git diff --quiet; then
echo 'You need to update the pnpm-lock.yaml file (potentially after installing node-gyp)'
exit 1
fi
- name: build
run: pnpm -r build

- name: run detect-broken-ts-expect-error.sh
run: cd packages/commonwealth && ./scripts/detect-broken-ts-expect-error.sh

# These tests run quickly, so run them in a separate job
commonwealth-unit-integration:
Expand Down
3 changes: 1 addition & 2 deletions packages/commonwealth/server/routes/createAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ const createAddress = async (
req: TypedRequestBody<CreateAddressReq>,
res: TypedResponse<CreateAddressResp>,
) => {
// @ts-expect-error StrictNullChecks
const user = req.body.user;
const user = req.user;

// start the process of creating a new address. this may be called
// when logged in to link a new address for an existing user, or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,9 @@ const linkExistingAddressToCommunity = async (
verified: originalAddress.verified,
hex,
},
{ where: { id: existingAddress.id }, transaction },
{ where: { id: existingAddress.id }, transaction, returning: true },
);
// @ts-expect-error StrictNullChecks
addressId = updatedObj.id;
addressId = updatedObj[1][0].id!;
});
} else {
const newObj = await models.sequelize.transaction(async (transaction) => {
Expand Down
20 changes: 12 additions & 8 deletions packages/commonwealth/server/routes/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ type StatusResp = {
loggedIn?: boolean;
user?: {
id: number;
email: string;
emailVerified: boolean;
emailInterval: EmailNotificationInterval;
email?: string | null;
emailVerified?: boolean | null;
emailInterval?: EmailNotificationInterval;
jwt: string;
knockJwtToken: string;
addresses: AddressInstance[];
selectedCommunity: CommunityInstance;
isAdmin: boolean;
disableRichText: boolean;
disableRichText?: boolean;
communities: StarredCommunityResponse[];
};
communityWithRedirects?: CommunityWithRedirects[];
Expand Down Expand Up @@ -71,7 +71,7 @@ export const getUserStatus = async (models: DB, user: UserInstance) => {
]);

// get starred communities for user
const userCommunities = await sequelize.query(
const userCommunities = await sequelize.query<StarredCommunityResponse>(
`
SELECT
id,
Expand Down Expand Up @@ -106,6 +106,7 @@ export const getUserStatus = async (models: DB, user: UserInstance) => {
replacements: {
user_id: user.id,
},
type: QueryTypes.SELECT,
},
);

Expand All @@ -123,7 +124,7 @@ export const getUserStatus = async (models: DB, user: UserInstance) => {
selectedCommunity,
isAdmin,
disableRichText,
communities: userCommunities?.[0] || [],
communities: userCommunities || [],
},
id: user.id,
email: user.email,
Expand Down Expand Up @@ -168,8 +169,11 @@ export const status = async (

return success(res, {
loggedIn: true,
// @ts-expect-error StrictNullChecks
user,
user: {
...user,
id: user.id!,
isAdmin: user.isAdmin ?? false,
},
communityWithRedirects: communityWithRedirects || [],
evmTestEnv: config.TEST_EVM.ETH_RPC,
enforceSessionKeys: config.ENFORCE_SESSION_KEYS,
Expand Down

0 comments on commit 51f6f0c

Please sign in to comment.