I managed to use js-based components in a typescript environment by disabling eslint and tslint just for those components:
I put all my js-based components into /js/ directory in my project.
I added ignorePatterns to .eslintrc.js:
ignorePatterns: [
"**/js/*.vue",
"**/js/*.js",
],
- I added
exclude to tsconfig.json:
"exclude": [
"node_modules",
"src/**/js/*.vue",
"src/**/js/*.js"
]
That made it work.
Here is my full configs for reference:
.eslintrc.js:
module.exports = {
root: true,
env: {
node: true
},
extends: [
'plugin:vue/essential',
'eslint:recommended',
'@vue/typescript/recommended',
],
parserOptions: {
ecmaVersion: 2020,
project: "./tsconfig.json",
createDefaultProgram: true,
async: false,
},
ignorePatterns: [
"**/js/*.vue",
"**/js/*.js",
],
rules: {
"no-throw-literal": "error",
"no-return-await": "error",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/ban-ts-ignore": ["error"],
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/explicit-function-return-type": ["error"],
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/no-unused-vars": ["error"],
"@typescript-eslint/restrict-plus-operands": ["error"],
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/return-await": ["error", "always"],
"@typescript-eslint/no-unsafe-call": ["error"],
"@typescript-eslint/no-unsafe-return": ["error"],
"@typescript-eslint/no-unsafe-member-access": ["error"],
"@typescript-eslint/no-unused-vars-experimental": ["error"],
"@typescript-eslint/no-unused-expressions": ["error"],
"@typescript-eslint/unbound-method": ["error"],
"@typescript-eslint/strict-boolean-expressions": ["error"],
"@typescript-eslint/no-throw-literal": ["error"],
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
}
}
tsconfig.json:
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"jsx": "preserve",
"allowJs": false,
"moduleResolution": "node",
"strict": true,
"importHelpers": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noUnusedParameters": true,
"strictNullChecks": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"noErrorTruncation": true,
"strictBindCallApply": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"emitDecoratorMetadata": true,
"noEmitOnError": true,
"baseUrl": ".",
"types": [
"webpack-env",
"jest"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": [
"node_modules",
"src/**/js/*.vue",
"src/**/js/*.js"
]
}
declare var someVueComponent:anyor write the defs yourself.