若依vue3项目js版本集成typeScript

下载typeScript

在package.json里加入typeScript在这里插入图片描述

添加类型声明文件

在这里插入图片描述

axios.d.ts

import * as axios from 'axios';

declare module 'axios' {
   
    interface AxiosInstance {
   
        (config: AxiosRequestConfig): Promise<any>;
    }
}

env.d.ts

/// <reference types="vite/client" />

declare module "*.vue" {
   
	import type {
    DefineComponent } from "vue";
	// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
	const component: DefineComponent<{
   }, {
   }, any>;
	export default component;
}

//环境变量 TypeScript的智能提示
interface ImportMetaEnv {
   
	VITE_APP_TITLE: string;
	VITE_APP_PORT: string;
	VITE_APP_BASE_API: string;
}

interface ImportMeta {
   
	readonly env: ImportMetaEnv;
}

vue-shim.d.ts

declare module "*.vue" {
   
  import Vue from "vue";
  export default Vue;
}

auto-imports.d.ts

// Generated by 'unplugin-auto-import'
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值