Skip to content

Fix some type issues. #18241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions cocos/core/curves/bezier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ const sqrt = Math.sqrt;

function crt (v: number): number {
if (v < 0) {
return -Math.pow(-v, 1 / 3);
return -((-v) ** (1 / 3));
} else {
return Math.pow(v, 1 / 3);
return v ** (1 / 3);
}
}

Expand Down Expand Up @@ -85,11 +85,11 @@ function cardano (curve: BezierControlPoints, x: number): any {
// and determine the discriminant:
const discriminant = q2 * q2 + p3 * p3 * p3;
// and some reserved variables
let u1;
let v1;
let x1;
let x2;
let x3;
let u1: number;
let v1: number;
let x1: number;
let x2: number;
let x3: number;

// If the discriminant is negative, use polar coordinates
// to get around square roots of negative numbers
Expand Down Expand Up @@ -144,9 +144,8 @@ function cardano (curve: BezierControlPoints, x: number): any {
} else {
return x2;
}
}
// one real root, and two imaginary roots
else {
} else {
// one real root, and two imaginary roots
const sd = sqrt(discriminant);
u1 = crt(-q2 + sd);
v1 = crt(q2 + sd);
Expand Down
2 changes: 1 addition & 1 deletion cocos/core/curves/curve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ export class RealCurve extends KeyframeCurve<RealKeyframeValue> {
if (values !== undefined) {
assertIsTrue(Array.isArray(times));
this.setKeyframes(
times.slice(),
(times as number[]).slice(),
values.map((value) => createRealKeyframeValue(value)),
);
} else {
Expand Down
2 changes: 1 addition & 1 deletion cocos/core/curves/keyframe-curve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export class KeyframeCurve<TKeyframeValue> implements CurveBase, Iterable<KeyFra
if (values !== undefined) {
assertIsTrue(Array.isArray(times));
this.setKeyframes(
times.slice(),
(times as number[]).slice(),
values.slice(),
);
} else {
Expand Down
3 changes: 1 addition & 2 deletions cocos/core/curves/keys-shared-curves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

import { ccclass, serializable } from 'cc.decorator';
import { binarySearchEpsilon } from '../algorithm/binary-search';
import { ccclass, serializable } from '../data/decorators';
import { assertIsTrue } from '../data/utils/asserts';
import { approx, IQuatLike, lerp, Quat } from '../math';
import { ExtrapolationMode, RealCurve } from './curve';
Expand Down
2 changes: 1 addition & 1 deletion cocos/core/curves/quat-curve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export class QuatCurve extends KeyframeCurve<QuatKeyframeValue> {
if (values !== undefined) {
assertIsTrue(Array.isArray(times));
this.setKeyframes(
times.slice(),
(times as number[]).slice(),
values.map((value) => createQuatKeyframeValue(value)),
);
} else {
Expand Down
Loading