`useStorage` got ts error TS2339
See original GitHub issueIn my nuxt 2 project
import { computed, Ref } from '@vue/composition-api'
import { useWindowSize, createGlobalState, useStorage } from '@vueuse/core'
export const useVerticalSizeState = createGlobalState(() =>
useStorage(
'use-vertical-size',
{
aspectRatio: 9 / 16,
},
sessionStorage,
),
)
export function useVerticalSize() {
const { width: windowWidth, height: windowHeight } = useWindowSize()
const state = useVerticalSizeState()
const aspectRatio = computed(() => state.value.aspectRatio)
const width = computed(() =>
Math.min(windowWidth.value, windowHeight.value * aspectRatio.value),
)
const height = computed(() => windowHeight.value)
const setAspectRatio = (aspectRatio: Ref<number>) => {
state.value.aspectRatio = aspectRatio.value
}
return {
width,
height,
aspectRatio,
setAspectRatio,
}
}
got this error
ERROR in utils/useVerticalSize.ts:21:44
TS2339: Property 'value' does not exist on type 'Omit<Ref<{ aspectRatio: number; }>, "value">'.
19 | const state = useVerticalSizeState()
20 |
> 21 | const aspectRatio = computed(() => state.value.aspectRatio)
| ^^^^^
22 | const width = computed(() =>
23 | Math.min(windowWidth.value, windowHeight.value * aspectRatio.value),
24 | )
ERROR in utils/useVerticalSize.ts:27:11
TS2339: Property 'value' does not exist on type 'Omit<Ref<{ aspectRatio: number; }>, "value">'.
25 | const height = computed(() => windowHeight.value)
26 | const setAspectRatio = (aspectRatio: Ref<number>) => {
> 27 | state.value.aspectRatio = aspectRatio.value
| ^^^^^
28 | }
29 |
30 | return {
obviously the problem lies in my editor’s inability to correctly interpret RemoveableRef
but I don’t want to overwrite the definition to solve the problem
19 | const state = useVerticalSizeState()
I need a hint…this is my tsconfig.json
{
"extends": "@tsconfig/node12/tsconfig.json",
"compilerOptions": {
"target": "es2018",
"module": "esnext",
"lib": ["ESNext", "DOM", "DOM.Iterable"],
"moduleResolution": "node",
"esModuleInterop": true,
"strict": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"declaration": true,
"declarationDir": "./types",
"resolveJsonModule": true,
"rootDir": ".",
"baseUrl": ".",
"paths": {
"~/*": ["./*"],
"@/*": ["./*"]
},
"types": [
"@types/node",
"@nuxt/types",
"@nuxtjs/axios",
"@nuxtjs/auth-next",
"@nuxtjs/dayjs",
"nuxt-i18n",
"vuetify",
"animejs"
],
"typeRoots": ["./node_modules/@types", "./node_modules/vuetify/types"]
},
"exclude": ["node_modules", ".nuxt", "dist"]
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Property 'filter' does not exist on type object - Stack Overflow
I'm working with zustand and typescript. I got this error on my code. Property ...
Read more >On static method Error TS2339: Property 'then' does not exist ...
On static method Error TS2339: Property 'then' does not exist on type '() => Promise' #10156.
Read more >TypeScript errors and how to fix them
A list of common TypeScript errors and how to fix them.
Read more >Typescript Type System: How Does it Really Work? Type ...
Let's have a look at the error message we get: Error:(54, 6) TS2339:Property 'name' does not exist on type '{}'. So what is ......
Read more >useLocalStorage() react hook - usehooks-ts
Persist the state with local storage so that it remains after a page refresh. This can be useful for a dark theme. This...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
What’s your TS version? Upgrade to v4.4 if possible
Thank you very much for your suggestion @mao-shonen. Let me try upgrading to the nuxt bridge.