我刚开始使用TypeScript和Deno。我以前从未进行过任何前端开发工作。
由于我正在使用Deno,因此需要从CDN导入所有内容作为URL导入。在我的TS文件中,我有:
import { LitElement, customElement, html } from 'https://cdn.pika.dev/lit-element';
我的IDE提示我无法找到模块:
Cannot find module 'https://cdn.pika.dev/lit-element' or its corresponding type declarations.ts(2307)
Could not find module "https://cdn.pika.dev/lit-element" locally.Deno Language Server(1005)
这是我的tsconfig.json
文件:
{
"compilerOptions": {
"experimentalDecorators": true
}
}
程序运行良好,但IDE错误实在令人烦恼,我希望解决它。作为一个新开发者,这些警告对于弄清楚事情很重要,所以假阳性非常让人沮丧 :/
deno
中,你需要在导入的URL末尾添加.ts
。 - MohamadrezaRahimianGolkhandanihttps://cdn.skypack.dev/pin/lit-element@v2.4.0-1XOpe9DTEoAR5DmPqDi1/min/lit-element.js
替换了,但仍然出现Cannot find module 'https://cdn.pika.dev/lit-element' or its corresponding type declarations.ts(2307)
错误。 - Nimrod Sadeh