Skip to content

Commit 45d2c0a

Browse files
committed
add typechecking
1 parent 22e6d00 commit 45d2c0a

File tree

6 files changed

+464
-28
lines changed

6 files changed

+464
-28
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ jobs:
2828

2929
- name: test
3030
run: yarn test
31+
32+
- name: astro check
33+
run: yarn typecheck

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"lint:eslint": "eslint . --ext .ts,.js --fix",
3030
"lint:format": "prettier --write '**/*.{ts,js,tsx,jsx,astro,vue,svelte,json,md,yml}'",
3131
"prepack": "yarn test && yarn build",
32-
"prepare": "husky install"
32+
"prepare": "husky install",
33+
"typecheck": "astro check && tsc --noEmit && svelte-check && vue-tsc --noEmit --p tsconfig.vue.json"
3334
},
3435
"author": "",
3536
"license": "MPL-2.0",
@@ -46,6 +47,7 @@
4647
"ethers": "^6.0.0"
4748
},
4849
"devDependencies": {
50+
"@astrojs/check": "^0.3.1",
4951
"@astrojs/svelte": "^4.0.3",
5052
"@astrojs/tailwind": "^5.0.0",
5153
"@astrojs/vue": "^3.0.0",
@@ -79,10 +81,12 @@
7981
"rxjs": "^7.8.1",
8082
"sass": "1.69.5",
8183
"svelte": "^4.2.3",
84+
"svelte-check": "^3.6.0",
8285
"tailwindcss": "3.3.5",
8386
"typescript": "5.2.2",
8487
"vite-plugin-node-polyfills": "^0.16.0",
85-
"vue": "3.3.8"
88+
"vue": "3.3.8",
89+
"vue-tsc": "^1.8.22"
8690
},
8791
"ava": {
8892
"files": [

src/components/ConnectButton.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const provider = ref<IProvider | null | undefined>()
2020
const showModal = ref(false)
2121
const userInfo = ref<Partial<UserInfo>>()
2222
let web3auth: UndefinedOr<IWeb3Auth>
23-
let connection: UndefinedOr<typeof Connection>
23+
let connectionPool: UndefinedOr<typeof Connection>
2424
2525
const truncatedAddress = computed(() => {
2626
const match = account.value?.match(
@@ -81,11 +81,9 @@ onMounted(async () => {
8181
await web3auth.initModal()
8282
loaded.value = true
8383
84-
const { connection: conn } = await import(
85-
'@devprotocol/clubs-core/connection'
86-
)
87-
connection = conn
84+
const { connection } = await import('@devprotocol/clubs-core/connection')
8885
86+
// @ts-ignore
8987
connection().account.subscribe((_account) => {
9088
account.value = _account
9189
if (_account && props.redirectOnSignin) {
@@ -95,23 +93,25 @@ onMounted(async () => {
9593
).toString()
9694
}
9795
})
96+
// @ts-ignore
9897
connection().chain.subscribe((chain) => {
9998
error.value = whenDefined(chain, (chainId) =>
10099
props.chainId && chainId !== props.chainId // There might be a case where we don't have chainId in props (eg. signin, publish flow, etc)
101100
? new Error(`Wrong chain: Please switch it to ${defaultChain.name}`)
102101
: undefined,
103102
)
104103
})
104+
connectionPool = connection
105105
})
106106
107107
watch(provider, async (prov) => {
108-
const res = !connection
108+
const res = !connectionPool
109109
? new Error('clubs-core/connection not initialized yet')
110110
: prov
111-
? await connection()
111+
? await connectionPool()
112112
.setEip1193Provider(prov, BrowserProvider)
113113
.then(() => true)
114-
: connection().signer.next(undefined)
114+
: connectionPool().signer.next(undefined)
115115
error.value = isNotError(res) ? undefined : res
116116
})
117117
</script>

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"include": [
1414
"src",
15-
"preview",
15+
".preview",
1616
"config.js",
1717
"rollup.config.js",
1818
"rollup.config.ui.js",

tsconfig.vue.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"include": ["**/*.vue"],
4+
"exclude": ["**/*.tsx"]
5+
}

0 commit comments

Comments
 (0)