简体   繁体   English

找不到模块'../constants/links'的声明文件| src / constants / links.js'隐式具有'any'类型

[英]Could not find a declaration file for module '../constants/links' | src/constants/links.js' implicitly has an 'any' type

In my VueJS app I've imported some constant variables. 在我的VueJS应用程序中,我导入了一些常量变量。

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator'
import { MOON_HOLDINGS_LINK, TWITTER_LINK } from '../constants/links'

@Component
export default class HelloWorld extends Vue {
  @Prop() private title!: string

  links = {
    moon: MOON_HOLDINGS_LINK,
    twitter: TWITTER_LINK
  }
}
</script>

The markup: 标记:

<p>
  Our first product is <a v-bind:href="links.moon" target="_blank">Moon.holdings</a>, a gamified cryptocurrency portfolio. We are currently working on a roadmap to introduce user accounts and gamified elements to help grow your crypto wealth.
</p>
<div>
  <a v-bind:href="links.twitter" target="_blank"><img src="../assets/twitter.png" alt="Follow us on Twitter"/></a>
</div>

And they both work fine in my app, and do click to those links: 它们都可以在我的应用程序中正常运行,并单击以下链接:

在此处输入图片说明

However I'm getting this strange error: 但是我收到这个奇怪的错误:

ERROR in /Users/leongaban/projects/Futuratum/futuratum.io/src/components/HelloWorld.vue 18:50 Could not find a declaration file for module '../constants/links'. /Users/leongaban/projects/Futuratum/futuratum.io/src/components/HelloWorld.vue中的错误18:50找不到模块'../constants/links'的声明文件。 '/Users/leongaban/projects/Futuratum/futuratum.io/src/constants/links.js' implicitly has an 'any' type. “ /Users/leongaban/projects/Futuratum/futuratum.io/src/constants/links.js”隐式具有“ any”类型。

My syntax looks 100% fine to me, but what am I missing here in VueJS? 我的语法对我来说100%不错,但是VueJS在这里我缺少什么?

在此处输入图片说明

您需要为links.js编写一个类型定义文件,也许vue在提取导入时正在使用--noImplicityAny或--strict,可以将其关闭。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到模块的声明文件。 &#39;/path/to/module-name.js&#39;隐式具有&#39;any&#39;类型 - Could not find a declaration file for module. '/path/to/module-name.js' implicitly has an 'any' type 无法找到隐式具有“任何”类型的模块的声明文件 - 在导入部分 CommonJS 模块时 - Could not find a declaration file for module implicitly has an 'any' type - while importing part of CommonJS module 反应/节点构建错误。 找不到模块“历史”的声明文件。 &#39;node_modules/history/index.js&#39; 隐含一个 &#39;any&#39; 类型 - React/node build error. Could not find a declaration file for module 'history'. 'node_modules/history/index.js' implicitly has an 'any' type 为任何文件类型JS创建下载链接 - create download links for any file type JS 找不到模块的声明文件 - Could not find a declaration file for module 在 react/typescript 常量中混合字符串和 html 链接 - Mixing strings and html links in react/typescript constants 找不到模块 'bootstrap/dist/js/bootstrap 的声明文件 - Could not find a declaration file for module 'bootstrap/dist/js/bootstrap 找不到模块“mymodule”的声明文件 - Could not find a declaration file for module 'mymodule' 无法找到模块&#39;drivelist&#39;的声明文件 - Could not find a declaration file for module 'drivelist' 在 JavaScript 中将函数声明为常量 - Declaration of functions in JavaScript as constants
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM