Skip to content

Commit a9cf152

Browse files
committed
docs(motion): 更正 GsapTimeline 的 TS6133 机理
1 parent 19a2a95 commit a9cf152

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

‎app/src/motion/engine.ts‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,17 @@ export { gsap, useGSAP };
5353

5454
/**
5555
* `gsap.core.Timeline` 的**转出**(计划 T10 Interfaces 逐字:`export type { gsap }` 转不出命名空间成员)。
56-
* ⚠️ **这是便利,不是类型检查的必需品**(T13b 按合并评审 I-2 更正了本段的旧说法):旧注释称
56+
* ⚠️ **这是便利,不是类型检查的必需品**(T13b 按合并评审 I-2 更正本段的旧说法):旧注释称
5757
* 「`import { gsap } from "gsap"` 绑定的**值**会遮蔽 `gsap` 这个**全局命名空间** ⇒ 使用方直接写
58-
* `gsap.core.Timeline` 过不了类型检查」—— **实测为假**(同一棵提交树上三个 tsc case):① 消费方
59-
* `import { gsap } from "./engine"` 后写 `gsap.core.Timeline` ⇒ **exit 0**;② **不 import 任何东西**
60-
* 直接写该类型 ⇒ **exit 0**;③ 阳性对照(同树 `app/src/**` 新文件里故意写错类型)⇒ **exit 2 / TS2322**
61-
* —— 前两个 0 **不是**「没检查」。它今天仍被两处以 `import type` 消费(`motion/controls.ts` /
62-
* `test/motionHarness.ts`,类型边不进产物),留着是因为**这个别名读起来稳、且是计划冻结的接口面**。
58+
* `gsap.core.Timeline` 过不了类型检查」—— **因果为假**:类型位置上的 `gsap.core.Timeline` 解析的是
59+
* gsap 自己声明的**全局命名空间**,与是否 import 无关。T13b 在同一棵提交树上以六个 tsc case 实测:
60+
* · **不 import** 任何东西直接写它 ⇒ **exit 0**;· import 了 `gsap` 且**值也真用到**(`gsap.timeline`)
61+
* 再在类型位置写它 ⇒ **exit 0**;· 唯一会红的是「import 了**值**却**只**在类型位置用它」⇒
62+
* **exit 2 / TS6133**(`noUnusedLocals` 判「值从未被读」,**不是**类型解析失败;从 `"gsap"` 直接
63+
* import 是同一机理、同一报错);· 阳性对照(同树 `app/src/**` 新文件里故意写错类型)⇒
64+
* **exit 2 / TS2322** —— 那几个 0 **不是**「没检查」。
65+
* ⇒ 别名的真实价值:消费方写 `import type { GsapTimeline }`(类型边不进产物、也不会撞上 TS6133)——
66+
* `motion/controls.ts` / `test/motionHarness.ts` 今天正是这么用的;删掉本行 ⇒ 两处 **TS2305**、exit 2
67+
* (故它**不是**没人用的装饰)。留着的另一个理由是它是**计划冻结的接口面**。
6368
*/
6469
export type GsapTimeline = gsap.core.Timeline;

0 commit comments

Comments
 (0)