-
I filed a ticket against What did you do? computed: {
alwaysBound(): string {
return "Always bound!";
},
},
methods: {
// Computed properties trigger the error
getAlwaysBound(): string {
const alwaysBound = this.alwaysBound; // <-- ERROR!
return alwaysBound;
},
// As do instance methods
logAlwaysBound(): string {
const alwaysBound = this.getAlwaysBound(); // <-- ERROR!
console.log(this.getAlwaysBound()); // <-- ERROR!
}, What did you expect to happen? What actually happened? Hitting this for all uses of computed properties and methods, which are all automatically bound by Vue already.
import {
defineConfigWithVueTs,
vueTsConfigs,
} from "@vue/eslint-config-typescript";
import { globalIgnores } from "eslint/config";
import prettierConfig from "@vue/eslint-config-prettier";
import standard from "@vue/eslint-config-standard-with-typescript";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import vueParser from "vue-eslint-parser";
import js from "@eslint/js";
import pluginVue from "eslint-plugin-vue";
import storybook from "eslint-plugin-storybook";
export default defineConfigWithVueTs(
globalIgnores([
"node_modules",
"dist/",
"components/*/dist/",
"**/index.d.ts",
]),
js.configs.recommended,
standard,
storybook.configs["flat/recommended"],
vueTsConfigs.recommendedTypeChecked,
pluginVue.configs["flat/recommended"],
prettierConfig,
{
name: "our-project/base",
files: ["**/*.{js,jsx,ts,tsx,vue}"],
languageOptions: {
globals: {
...globals.node,
...globals.browser,
},
sourceType: "module",
ecmaVersion: "latest",
parser: vueParser,
parserOptions: {
parser: tsParser,
projectService: true,
sourceType: "module",
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
[…]
}
}
);
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"jsx": "preserve",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"resolveJsonModule": true,
"verbatimModuleSyntax": true,
"types": ["node", "vue", "vitest/globals"],
"allowJs": true,
"checkJs": true,
},
"include": [
"**/*.ts",
"**/*.tsx",
"**/*.vue",
"**/*.js",
],
"extends": [
"@vue/tsconfig/tsconfig.dom.json",
"@vue/tsconfig/tsconfig.lib.json"
],
"exclude": ["node_modules", "types", "dist"]
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
As an alternative, you can try tsslint, which has first-party Vue support based on |
Beta Was this translation helpful? Give feedback.
Sorry, haven't had time to figure out the minimum reproduction (our project is quite large), but I managed to find a couple of fixes/workarounds, one of which was intended for Vue 2 even though we are on the latest Vue 3 and
vue-tsc
. It's unclear which one(s) are the "actual" cause(s), but these helped:Manually type
mapState
,mapGetters
, etc.For computed variables / component properties & methods issue, this worked well for some cases (for example in a component library where the final type for your Vuex or Pinia store can't be specified yet: https://stackoverflow.com/a/70983629/2836299
Use of deprecated
computed
cache invalidationTrying to invalidate cache for computed variables as de…