error TS9005: Declaration emit for this file requires using private name 'xxx'. An explicit type annotation may unblock declaration emit.

发布时间 2023-04-07 14:34:31作者: 贝尔塔猫

error TS9005: Declaration emit for this file requires using private name 'distance'. An explicit type annotation may unblock declaration emit.

代码如下:

/**
 * 计算两个坐标之间的距离
 * @param pnt1
 * @param pnt2
 * @returns {number}
 * @constructor
 */
export const distance2 = (pnt1, pnt2) => {
    return Math.sqrt(Math.pow(pnt1[0] - pnt2[0], 2) + Math.pow(pnt1[1] - pnt2[1], 2))
}

 

解决方案:将 @constructor 注释移除(可能是无意间手误生成的注释)。

/**
 * 计算两个坐标之间的距离
 * @param pnt1
 * @param pnt2
 * @returns {number}
 */
export const distance2 = (pnt1, pnt2) => {
    return Math.sqrt(Math.pow(pnt1[0] - pnt2[0], 2) + Math.pow(pnt1[1] - pnt2[1], 2))
}

 

问题解决,原理未知。稍后补充。