From ed1ebd2e2109aca68f678fbefa6a36caa77429cf Mon Sep 17 00:00:00 2001 From: Yulong Wang Date: Wed, 27 Jan 2021 15:32:45 -0800 Subject: [PATCH] fix SDL rule (#6464) --- nodejs/lib/tensor-impl.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nodejs/lib/tensor-impl.ts b/nodejs/lib/tensor-impl.ts index 390aeca1b4..58ef3137fe 100644 --- a/nodejs/lib/tensor-impl.ts +++ b/nodejs/lib/tensor-impl.ts @@ -87,20 +87,20 @@ export class Tensor implements TensorInterface { data = arg1; } else { // numeric tensor - const constructor = NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.get(arg0); - if (constructor === undefined) { + const typedArrayConstructor = NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.get(arg0); + if (typedArrayConstructor === undefined) { throw new TypeError(`Unknown tensor type: ${arg0}.`); } if (Array.isArray(arg1)) { // use 'as any' here because TypeScript's check on type of 'SupportedTypedArrayConstructors.from()' produces // incorrect results. - // 'constructor' should be one of the typed array prototype objects. + // 'typedArrayConstructor' should be one of the typed array prototype objects. // eslint-disable-next-line @typescript-eslint/no-explicit-any - data = (constructor as any).from(arg1); - } else if (arg1 instanceof constructor) { + data = (typedArrayConstructor as any).from(arg1); + } else if (arg1 instanceof typedArrayConstructor) { data = arg1; } else { - throw new TypeError(`A ${type} tensor's data must be type of ${constructor}`); + throw new TypeError(`A ${type} tensor's data must be type of ${typedArrayConstructor}`); } } } else {