Skip to content

Commit

Permalink
ENG-0000 fix(portal,1ui): resolve all remaining typescript and build …
Browse files Browse the repository at this point in the history
…issues (#466)

## Affected Packages

Apps

- [x] portal

Packages

- [x] 1ui
- [ ] api
- [ ] protocol
- [ ] sdk

Tools

- [ ] tools

## Overview

- Stop tsc from checking types of consumed packages
- Fix remaining type errors in portal
- Make 1ui emit types and the have it be a `composite` library so that
the types can be included as references in portal

Source:
microsoft/TypeScript#38538 (comment)

## Screen Captures

If applicable, add screenshots or screen captures of your changes.

## Declaration

- [x] I hereby declare that I have abided by the rules and regulations
as outlined in the
[CONTRIBUTING.md](https://github.com/0xIntuition/intuition-ts/blob/main/CONTRIBUTING.md)
  • Loading branch information
rahulr8 authored Aug 6, 2024
1 parent fc2e334 commit d852ab9
Show file tree
Hide file tree
Showing 21 changed files with 44 additions and 34 deletions.
2 changes: 1 addition & 1 deletion apps/portal/app/components/follow/follow-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default function FollowForm({
<div className="w-full bg-neutral-50/5 rounded-lg border border-neutral-300/10 flex-col justify-start items-start inline-flex">
<ActivePositionCard
value={Number(formatBalance(user_assets, 18, 4))}
claimPosition={`${user_assets > '0' ? 'claimFor' : ''}`}
claimPosition={user_assets > '0' ? 'claimFor' : null}
/>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion apps/portal/app/components/list/activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function ActivityItem({
<ClaimRow
claimsFor={activity.claim.for_num_positions}
claimsAgainst={activity.claim.against_num_positions}
amount={+formatBalance(activity.claim.assets_sum, 18, 4)}
tvl={+formatBalance(activity.claim.assets_sum, 18, 4)}
onClick={() => {
if (activity.claim) {
navigate(`${PATHS.CLAIM}/${activity.claim.claim_id}`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
Button,
CurrencyType,
Icon,
Identity,
Text,
TextVariant,
TextWeight,
Expand Down Expand Up @@ -32,7 +31,7 @@ export const ListIdentityCardPortal: React.FC<ListIdentityCardPortalProps> = ({
style={{ height: '18rem' }}
>
<Avatar
variant={Identity.nonUser as unknown as number}
variant="non-user"
src={imgSrc}
name={displayName}
className="mb-4 w-16 h-16"
Expand Down
2 changes: 1 addition & 1 deletion apps/portal/app/components/list/save-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default function SaveForm({
<div className="w-full bg-neutral-50/5 rounded-lg border border-neutral-300/10 flex-col justify-start items-start inline-flex">
<ActivePositionCard
value={Number(formatBalance(user_assets, 18, 4))}
claimPosition={`${user_assets > '0' ? 'claimFor' : ''}`}
claimPosition={user_assets > '0' ? 'claimFor' : null}
/>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion apps/portal/app/components/profile/connections-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface ConnectionsHeaderProps {
variant: ConnectionsHeaderVariantType
subject: IdentityPresenter
predicate: IdentityPresenter
object: IdentityPresenter
object: IdentityPresenter | null
claim_id: string
totalFollowers: number
totalStake: string
Expand Down
1 change: 1 addition & 0 deletions apps/portal/app/components/tags/tags-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function TagsModal({
}}
>
<DialogContent className="bg-neutral-950 rounded-xl shadow border border-solid border-black/10 h-[550px] overflow-hidden flex flex-col">
{/* @ts-ignore TODO: jp - userWallet is a required prop. Where should it come from? */}
<TagsForm
identity={identity}
mode={mode}
Expand Down
1 change: 1 addition & 0 deletions apps/portal/app/lib/state/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const addIdentitiesListModalAtom = atom<{
id: null,
})

// @ts-ignore TODO: jp - identity is passed as a prop to atom, but it does not exist in the atom definition
export const saveListModalAtom = atom<{
isOpen: boolean
id: string | null
Expand Down
2 changes: 2 additions & 0 deletions apps/portal/app/lib/utils/quest.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck content-collections folder is not available at build time
import { QuestCondition } from '@0xintuition/api'

import { allQuests, QuestContentType } from 'content-collections'
Expand Down
2 changes: 1 addition & 1 deletion apps/portal/app/routes/app+/quest+/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { Suspense } from 'react'

import {
formatWalletAddress,
ProfileCardHeader,
Separator,
Skeleton,
Text,
} from '@0xintuition/1ui'
import { ProfileCardHeader } from '@0xintuition/1ui/src/components/ProfileCard/components'
import {
GetUserByWalletResponse,
QuestNarrative,
Expand Down
3 changes: 1 addition & 2 deletions apps/portal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"build": "remix vite:build --emptyOutDir",
"dev": "remix vite:dev",
"start": "NODE_OPTIONS='--import ./instrumentation.server.mjs' PORT=8080 remix-serve ./build/server/index.js",
"lint:fix": "pnpm lint --fix",
"typecheck": "tsc --noEmit -p ./tsconfig.json"
"lint:fix": "pnpm lint --fix"
},
"repository": {
"type": "git",
Expand Down
7 changes: 7 additions & 0 deletions apps/portal/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
"options": {
"config": "apps/portal/vitest.config.ts"
}
},
"typecheck": {
"dependsOn": ["^build"],
"command": "tsc",
"options": {
"cwd": "apps/portal"
}
}
}
}
7 changes: 6 additions & 1 deletion apps/portal/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,10 @@
"outDir": "./build"
},
"include": ["**/*.ts", "**/*.tsx", "tailwind.config.js"],
"exclude": ["node_modules", "dist", "**/packages/**/*"]
"exclude": ["node_modules", "build", "./.content-collections"],
"references": [
{
"path": "../../packages/1ui"
}
]
}
12 changes: 1 addition & 11 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
"dependsOn": ["^build", "typecheck"],
"outputs": ["{projectRoot}/dist"],
"cache": true
},
Expand All @@ -22,16 +22,6 @@
},
"typecheck": {
"cache": true
},
"@nx/js:tsc": {
"cache": true,
"dependsOn": ["^build"],
"inputs": ["default", "^default"]
},
"@nx/remix:build": {
"cache": true,
"dependsOn": ["^build"],
"inputs": ["default", "^default"]
}
},
"release": {
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
"1ui:lint": "nx lint @0xintuition/1ui",
"1ui:test": "nx test @0xintuition/1ui --reporter=verbose",
"1ui:typecheck": "nx typecheck @0xintuition/1ui",
"portal:dev": "nx dev @0xintuition/portal",
"portal:start": "nx start @0xintuition/portal",
"portal:typecheck": "nx typecheck @0xintuition/portal",
"api:build": "nx build @0xintuition/api",
"api:lint": "nx lint @0xintuition/api",
"portal:dev": "nx dev @0xintuition/portal",
"portal:start": "nx start @0xintuition/portal",
"portal:build": "nx build @0xintuition/portal",
"portal:lint": "nx lint @0xintuition/portal",
"portal:test": "nx test @0xintuition/portal --reporter=verbose",
Expand Down
1 change: 1 addition & 0 deletions packages/1ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.3.0",
"description": "Design system",
"main": "src/index.js",
"types": "src/index.d.ts",
"scripts": {
"dev": "tsup --watch",
"lint:fix": "pnpm lint --fix",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Tag, TagSize, TagVariant, Text, TextVariant } from '..'

export interface ActivePositionCardProps
extends React.HTMLAttributes<HTMLDivElement> {
claimPosition?: ClaimPositionType
claimPosition?: ClaimPositionType | null
value: number
currency?: CurrencyType
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ interface CommonProps extends React.HTMLAttributes<HTMLDivElement> {
feesAccrued: number
updatedAt?: string
tags?: TagWithValueProps[]
claimsForValue?: number
claimsAgainstValue?: number
}

interface UserVariantProps extends CommonProps {
variant: 'user'
claimsFor?: number
claimsAgainst?: number
claimsForValue?: number
claimsAgainstValue?: number
name: string
avatarSrc: string
walletAddress: string
Expand All @@ -46,8 +46,6 @@ interface ClaimVariantProps extends CommonProps {
variant: 'claim'
claimsFor: number
claimsAgainst: number
claimsForValue: number
claimsAgainstValue: number
name?: never
avatarSrc?: never
walletAddress?: never
Expand Down
8 changes: 4 additions & 4 deletions packages/1ui/src/components/ClaimRow/ClaimRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { CurrencyType } from 'types'
export interface ClaimRowProps extends React.HTMLAttributes<HTMLDivElement> {
claimsFor: number
claimsAgainst: number
claimsForValue: number
claimsAgainstValue: number
claimsForValue?: number
claimsAgainstValue?: number
tvl: number
currency?: CurrencyType
}
Expand All @@ -17,8 +17,8 @@ const ClaimRow = ({
claimsFor = 0,
claimsAgainst = 0,
tvl,
claimsForValue,
claimsAgainstValue,
claimsForValue = 0,
claimsAgainstValue = 0,
currency,
children,
className,
Expand Down
1 change: 1 addition & 0 deletions packages/1ui/src/components/ProfileCard/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './ProfileCard'
export * from './components'
6 changes: 6 additions & 0 deletions packages/1ui/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import './styles/globals.css'

export * from './styles'
export * from './components'
export * from './utils'
export * from './types'
3 changes: 2 additions & 1 deletion packages/1ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"compilerOptions": {
"jsx": "react-jsx",
"baseUrl": "./src",
"outDir": "../../dist/packages/1ui"
"outDir": "../../dist/packages/1ui",
"composite": true
},
"include": ["src"]
}

0 comments on commit d852ab9

Please sign in to comment.