我试图将Vuejs应用程序转换为增量式使用类型记录,并面临一些构建问题。应用程序的package.json显示"@vue/cli-plugin-typescript": "^4.3.1", "typescript": "^3.5.2",
我能够通过a创建.d.ts文件来修复几个构建问题,例如:我通过使用import VueTour from 'vue-tour';创建vue-tour.d.ts文件修复了与main.ts中的vue-tour.d.ts相关的构建错误
b.在生成行错误之前添加// @ts-ignore。例:
// @ts-ignore
import axios from "./axios.js";~\src\axios.js
import axios from 'axios'
const domain = ""
export default axios.create({domain})与使用// @ts-ignore不同,我如何创建一个.d.ts文件来解决构建问题?
我还构建了与AWS放大器生成的类型相关的错误,以及我们使用的自定义路由器实例。
解决这些构建问题的推荐方法是什么?
~\src\router.js
import Vue from 'vue';
import Router from 'vue-router';
Vue.use(Router);
const router = new Router({............
});
export default router;构建问题1:
126:10 No overload matches this call.
Overload 1 of 3, '(options?: ThisTypedComponentOptionsWithArrayProps<Vue, object, object, object, never> | undefined): CombinedVueInstance<Vue, object, object, object, Record<...>>', gave the following error.
Argument of type '{ router: any; store: any; i18n: any; acl: any; render: (h: CreateElement) => VNode; }' is not assignable to parameter of type 'ThisTypedComponentOptionsWithArrayProps<Vue, object, object, object, never>'.
Object literal may only specify known properties, and 'router' does not exist in type 'ThisTypedComponentOptionsWithArrayProps<Vue, object, object, object, never>'.
Overload 2 of 3, '(options?: ThisTypedComponentOptionsWithRecordProps<Vue, object, object, object, object> | undefined): CombinedVueInstance<Vue, object, object, object, Record<...>>', gave the following error.
Argument of type '{ router: any; store: any; i18n: any; acl: any; render: (h: CreateElement) => VNode; }' is not assignable to parameter of type 'ThisTypedComponentOptionsWithRecordProps<Vue, object, object, object, object>'.
Object literal may only specify known properties, and 'router' does not exist in type 'ThisTypedComponentOptionsWithRecordProps<Vue, object, object, object, object>'.
Overload 3 of 3, '(options?: ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>> | undefined): CombinedVueInstance<...>', gave the following error.
Argument of type '{ router: any; store: any; i18n: any; acl: any; render: (h: CreateElement) => VNode; }' is not assignable to parameter of type 'ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>>'.
Object literal may only specify known properties, and 'router' does not exist in type 'ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>>'.
124 |
125 | Vue.config.productionTip = false;
> 126 | new Vue({router, store, i18n, acl, render: h => h(App)}).$mount('#app');
| ^构建问题2:
ERROR in ~/node_modules/@aws-amplify/api-graphql/lib-esm/types/index.d.ts(3,21):
3:21 Cannot use namespace 'DocumentNode' as a type.
1 | import { DocumentNode } from 'graphql/language/ast';
2 | export interface GraphQLOptions {
> 3 | query: string | DocumentNode;
| ^
4 | variables?: object;
5 | authMode?: GRAPHQL_AUTH_MODE;tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": 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", "src/main.ts"
],
"exclude": [
"node_modules"
]
}发布于 2020-05-07 01:31:15
我将"skipLibCheck": true添加到tsconfig.json文件中以修复构建问题2。这应该是可以的,因为我们不想检查DocumentNode是否存在库依赖关系。
https://stackoverflow.com/questions/61627382
复制相似问题