package.json
{
"name": "application",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build ",
"lint": "vue-cli-service lint",
"dev": "vue-cli-service build --watch --mode=development",
"test": "jest tests/.*test.ts",
"watchTest": "jest --watch tests/.*test.ts"
},
"dependencies": {
"@quasar/extras": "^1.6.4",
"@types/node": "^14.0.3",
"axios": "^0.19.2",
"core-js": "^3.6.5",
"quasar": "^1.0.0",
"vue": "^2.6.11",
"vue-browser-acl": "^0.13.5",
"vue-class-component": "^7.2.3",
"vue-i18n": "^8.16.0",
"vue-infinite-loading": "^2.4.5",
"vue-moment": "^4.1.0",
"vue-property-decorator": "^8.4.2",
"vue2-dropzone": "^3.6.0",
"vuedraggable": "^2.23.2",
"vuex": "latest",
"vuex-class": "^0.3.2",
"vuex-module-decorators": "^0.16.1",
"vuex-persist": "^2.2.0"
},
"devDependencies": {
"@types/jest": "^25.2.1",
"@typescript-eslint/eslint-plugin": "^2.26.0",
"@typescript-eslint/parser": "^2.26.0",
"@vue/cli": "^4.3.1",
"@vue/cli-plugin-babel": "~4.3.0",
"@vue/cli-plugin-eslint": "~4.3.0",
"@vue/cli-plugin-typescript": "^4.3.1",
"@vue/cli-service": "^4.3.1",
"@vue/eslint-config-typescript": "^5.0.2",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.0.1",
"babel-plugin-transform-imports": "1.5.0",
"clean-webpack-plugin": "^3.0.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"html-loader": "^1.1.0",
"jest": "^26.0.1",
"node-sass": "^4.13.0",
"sass-loader": "^8.0.0",
"typescript": "~3.8.3",
"vue-cli-plugin-quasar": "~2.0.0",
"vue-template-compiler": "^2.6.11",
"webpack-assets-manifest": "^3.1.1"
},
"jest": {
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
"\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js"
}
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended",
"@vue/typescript"
],
"parserOptions": {
"parser": "@typescript-eslint/parser"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}
babel.config.js
module.exports = {
"presets": [
"@vue/cli-plugin-babel/preset"
],
"plugins": [
[
"transform-imports",
{
"quasar": {
"transform": "quasar/dist/babel-transforms/imports.js",
"preventFullImport": true
}
}
],
]
}
tsconfig.json
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"types": [
"webpack-env",
"jest",
"node",
"@types/jest"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": [
"node_modules"
]
}
说实话,我什至不知道这个错误是什么意思。开玩笑不懂typeSript吗?也许可以吗?当我尝试在Google中找到一些答案时,通常人们会遇到“导入”关键字而不是某些变量的问题。我尝试添加babel-plugin-proposal-class-properties,但这是最糟糕的。而且,由于我什至不理解此错误,并且在网上找不到类似的错误,因此很难做些什么。也许有人帮忙。
答案 0 :(得分:0)
也许您应该安装ts-jest
并在package.json中添加transform和moduleFileExtensions
{
"jest": {
"transform": {
'^.+\\.ts?$': 'ts-jest',
'.*\\.(vue)$': 'vue-jest'
},
"moduleFileExtensions": ['ts', 'js', 'vue']
}
}