On the problem of using typescript to refer to public js in vue-cli projects

the vue project I built through vue-cli3 selected the module that supports ts, and then wrote a public js file today. The error report is not declared when it is introduced with import in main.js, but it can be used. The error message is as follows:

21:23 Could not find a declaration file for module "./libs/commonFun.js". "E:///internal-recommended/src/libs/commonFun.js" implicitly has an "any" type.
    19 | Vue.config.devtools = true;
    20 | // js
  > 21 | import commonFun from "./libs/commonFun.js";
       |                       ^
    22 | Vue.prototype.commonFun = commonFun;
    23 |
    24 | new Vue({
Version: typescript 3.1.6

main.js introduction code is as follows

// js
import commonFun from "./libs/commonFun.js";
Vue.prototype.commonFun = commonFun;

commonFun.js is as follows

import {
    MessageBox
} from "element-ui";
export default {
    showConfirm(option) {
        MessageBox.confirm(option.confirmtxt, "", {
            confirmButtonText: option.confirmoktxt,
            cancelButtonText: option.confirmcanceltxt,
            type: "warning",
            center: true
        }).then(() => {
            option.success()
        }).catch(() => {
            console.log("")
        });
    }
}

because I used ts for the first time, I did not find the declaration of this kind of introduction file in the official document, and Baidu did not find the relevant information. I also asked the boss who thought no to help me to express my thanks.

May.14,2022

tsconfig.json

{
  "compilerOptions": {
    "allowJS": true,
    ...
  },
  ...
}

is the boss problem solved? I have the same problem


look at this, the d.ts file declares

if you look at some npm libraries that support ts, you will find that he will declare such xxx.d.ts files, which need to be declared.


has the landlord solved it?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37c20-2b608.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37c20-2b608.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?