如何在打字稿中导入Vanilla js ES6模块

问题描述 投票:1回答:1

我正在尝试导入该库:https://github.com/nextapps-de/spotlight这是普通的js。在我的项目中,我创建了一个伪造的d.ts:

declare module 'spotlight.js'

如VSCode所建议,然后我尝试了每个单独的导入组合:

import * as spotlight from 'spotlight';
import spotlight from 'spotlight';
import { spotlight } from 'spotlight';

但是在我的代码中,spotlight表达式始终是一个空对象。我想念什么?

javascript typescript es6-modules
1个回答
0
投票

声明语句最初必须在单独的文件中,还请确保您提供了正确的导入路径

[如果还是没用,对不起

© www.soinside.com 2019 - 2024. All rights reserved.