是否有必要为您在打字稿中使用的每个JS库打字? 如果没有,那么如何摆脱错误并利用一个没有可用定义文件的库
numbers = [173, 210, 94, 164]
counter = 0
while numbers != [0, 0, 0, 0]:
oldnums = numbers
numbers[0] = abs(oldnums[0] - oldnums[1])
numbers[1] = abs(oldnums[1] - oldnums[2])
numbers[2] = abs(oldnums[2] - oldnums[3])
numbers[3] = abs(oldnums[3] - oldnums[0])
print(numbers)
counter += 1
print('Number of iterations to (0,0,0,0): ' + str(counter))
无法找到反应通知的输入法
答案 0 :(得分:2)
没有必要。对于您的示例,您创建了一个文件react-notifications.d.ts
(只要扩展名为.d.ts
,您就可以将其称为任何内容,但为其命名一致是有意义的:
declare module "react-notifications" {
const NotificationContainer: any;
const NotificationManager: any;
}
这是一个接近极小的起点。但是你可以进一步改进那些any
声明。他们是临时警察。
答案 1 :(得分:1)
@Daniel Earwicker的替代方案回答,只要您处于commonJS环境中(我猜您使用的是webpack)就是使用节点require
require
库
const rn = require('react-notifications')
然后直接使用rn.NotificationContainer
或import NotificationContainer = rn.NotificationContainer