Typescript类型报错
报错:元素隐式具有 “any” 类型,因为索引表达式的类型不为 “number”
const GLOBAL_SYMBOL = Symbol.for('xxx');
if (!window[GLOBAL_SYMBOL]) {
window[GLOBAL_SYMBOL] = {};
}
根目录声明 global.d.ts:
declare interface Window {
[GLOBAL_SYMBOL: symbol]: {};
}
Could not find a declaration file for module ‘js-cookie’. ‘/Users/maoxunxing/alibaba/ae-data-util/node_modules/_js-cookie@3.0.1@js-cookie/index.js’ implicitly has an ‘any’ type.
解决方案:
declare module "js-cookie" {
export interface CookieAttributes {}
}
Be the first to know when I post cool stuff
Subscribe to get my latest posts by email.
Thanks for signing up! Check your email to confirm your subscription.
Whoops, we weren't able to process your signup.