victorybiz / vue-simple-acl

A simple unopinionated Vue plugin for managing user roles and permissions, access-control list (ACL) and role-based access control (RBAC).
https://github.com/victorybiz/vue-simple-acl
131 stars 24 forks source link

typing error in composition api for $can #17

Open morteza-mortezai opened 1 year ago

morteza-mortezai commented 1 year ago

Hi,

I'm using $can in component and I'm getting this error

Property '$can' does not exist on type '{ $: ComponentInternalInstance; $data: {} ....

package.json { "name": "", "version": "1.0.0", "private": true, "scripts": { "dev": "vite", "build": "run-p type-check build-only", "preview": "vite preview", "build-only": "vite build", "type-check": "vue-tsc --noEmit", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", "format": "prettier --write src/" }, "dependencies": { "@element-plus/icons-vue": "^2.1.0", "axios": "^1.3.5", "element-plus": "^2.3.3", "highcharts": "^10.3.3", "jenesius-vue-modal": "^1.8.2", "node-sass": "^8.0.0", "pinia": "^2.0.34", "sass": "^1.61.0", "sass-loader": "^13.2.2", "vue": "^3.2.47", "vue-3-export-excel": "^1.0.8", "vue-router": "^4.1.6", "vue-simple-acl": "^2.0.2" }, "devDependencies": { "@rushstack/eslint-patch": "^1.2.0", "@types/node": "^18.14.2", "@vitejs/plugin-vue": "^4.0.0", "@vue/eslint-config-prettier": "^7.1.0", "@vue/eslint-config-typescript": "^11.0.2", "@vue/tsconfig": "^0.1.3", "eslint": "^8.34.0", "eslint-plugin-vue": "^9.9.0", "npm-run-all": "^4.1.5", "prettier": "^2.8.4", "typescript": "~4.8.4", "vite": "^4.1.4", "vue-tsc": "^1.2.0" } }

blogui91 commented 1 year ago

I think this is not related to this package.

However, in any file d.ts you can do this:


declare module 'vue' {
  interface ComponentCustomProperties {
    $currentUser: CurrentUser;
  }
}

In this example I declared a variable that stores the current user.

I hope it can help