首页 > 解决方案 > 摆脱 no-inner-declaratioins eslint 错误的最佳方法是什么?

问题描述

我正在研究以这种方式使用模块的打字稿代码库。

export module Foo {

    const foos = []

    export function getFoos() {
        return getLastFoo();
    }

    function getLastFoo() {
        return foos[-1]
    }
}

错误截图:

在此处输入图像描述

我试图摆脱 no-inner-declarations eslint 错误。我想到的一种方法是用类替换模块。

export class Foo {

    static foos = []

    static getFoos() {
        return this.getLastFoo();
    }

    private static getLastFoo() {
        return this.foos[-1]
    }
}

有没有办法解决这个 eslint 错误而不必将模块更改为类?

标签: typescripteslint

解决方案


推荐阅读