diff --git a/.eslintrc.js b/.eslintrc.js index 9a921a5ee8..c9673384ed 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,6 +1,7 @@ module.exports = { extends: [ '@nextcloud', + '@nextcloud/eslint-config/typescript', ], globals: { // @nextcloud/webpack-vue-config globals @@ -12,6 +13,7 @@ module.exports = { rules: { 'comma-dangle': 'off', 'jsdoc/no-defaults': 'off', + '@typescript-eslint/no-unused-vars': 'off', 'import/newline-after-import': 'warn', 'import/no-named-as-default-member': 'off', 'import/order': [ diff --git a/jest.config.js b/jest.config.js index 4c669963a7..db9713b494 100644 --- a/jest.config.js +++ b/jest.config.js @@ -86,6 +86,12 @@ module.exports = { }, transform: { + '\\.ts$': ['ts-jest', { + useESM: true, + tsconfig: { + verbatimModuleSyntax: false, + }, + }], '\\.js$': 'babel-jest', '\\.vue$': '@vue/vue2-jest', '\\.tflite$': 'jest-transform-stub', diff --git a/tsconfig.json b/tsconfig.json index 93aa678778..fd3c5de2c2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,14 +1,20 @@ { - "include": ["./src/**/*.ts"], + "include": ["./src/**/*.ts", "./src/**/*.vue"], "exclude": ["node_modules", "vendor"], "compilerOptions": { "outDir": "./js", "allowJs": true, - "module": "CommonJS", + "checkJs": true, + "allowImportingTsExtensions": true, + "lib": ["ESNext"], + "module": "ESNext", "moduleResolution": "bundler", "verbatimModuleSyntax": true, "target": "ES2020", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, + }, + "vueCompilerOptions": { + "target": 2.7, } } diff --git a/webpack.common.config.js b/webpack.common.config.js index b5a5cce8f7..9a99270e78 100644 --- a/webpack.common.config.js +++ b/webpack.common.config.js @@ -31,6 +31,7 @@ module.exports = mergeWithRules({ test: 'match', loader: 'replace', options: 'replace', + use: 'replace', }, }, })({ @@ -62,6 +63,17 @@ module.exports = mergeWithRules({ 'webdav', ]), }, + { + test: /\.tsx?$/, + use: [{ + loader: 'esbuild-loader', + options: { + // Implicitly set as TS loader so only