Generic class in a reference cycle measured invariant in 7.1: `Link<Sub>` no longer assignable to `Link<EntityBase>` (@sap-cloud-sdk/odata-common)
維護者通常 1 天內回覆
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 46/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- go, typescript
研究方向
Start by comparing TypeScript 7.0.2 and 7.1 behavior with the supplied minimal reproduction and strict tsconfig; the issue identifies variance computation and a possible connection to microsoft/typescript-go#4820. Trace the reported Link → EntityApi → RequestBuilder → Selectable reference cycle and inspect the variance elaboration path. Done means the reproduction compiles as it did on 7.0.2 while preserving the reported assignability behavior.
由索引模型根據 Issue 內容生成。
描述
🔎 Search Terms
variance circularity, circular variance class, variance computed invariant, subclass type argument not assignable, @sap-cloud-sdk Link not assignable, 7.1 variance regression
🕗 Version & Regression Information
- This changed between versions 7.0.2 (gitHead 2bd066d8) and 7.1.0-beta (gitHead 3e923636)
- passes on 7.0.2, fails on 7.1.0-beta, 7.1.0-dev.20261022.1, 7.1.0-dev.20261027.1 and 7.1.0-dev.20261028.1
- same result with
--singleThreaded
⏯ Playground Link
n/a - needs the @sap-cloud-sdk/odata-common package
💻 Code
// repro.ts - @sap-cloud-sdk/[email protected], node 24.18
import type { DefaultDeSerializers, EntityApi, EntityBase, Link } from '@sap-cloud-sdk/odata-common';
type D = DefaultDeSerializers;
declare class Sub extends EntityBase { readonly _oDataVersion: 'v2'; id: string }
declare const l: Link<Sub, D, EntityApi<EntityBase, D>>;
export const l2: Link<EntityBase, D, EntityApi<EntityBase, D>> = l;
// tsconfig.json
{
"compilerOptions": { "strict": true, "noEmit": true, "module": "nodenext", "target": "es2022", "skipLibCheck": true },
"files": ["repro.ts"]
}
npm i @sap-cloud-sdk/[email protected] && tsc -p .
🙁 Actual behavior
repro.ts(6,14): error TS2322: Type 'Link<Sub, DefaultDeSerializers, EntityApi<EntityBase, DefaultDeSerializers>>' is not assignable to type 'Link<EntityBase, DefaultDeSerializers, EntityApi<EntityBase, DefaultDeSerializers>>'.
Property 'id' is missing in type 'EntityBase' but required in type 'Sub'.
🙂 Expected behavior
no error, like 7.0.2. Link only uses EntityT in covariant positions (readonly _entity: EntityT, readonly _entityApi: EntityApi<EntityT, DeSerializersT>), and EntityApi<Sub, D> is assignable to EntityApi<EntityBase, D> on 7.1 too
Additional information about the issue
copying Link and Selectable from the package into local files makes the same assignment pass on 7.1, so it seems to need the package's own reference cycle Link -> EntityApi<E> -> RequestBuilder<E> -> select(Selectable<E>) -> Link: the elaboration goes straight from Link to EntityBase vs Sub, as if Link's variance for EntityT was measured invariant without falling back to a structural check
possibly related: microsoft/typescript-go#4820 "Order variance computation by associated type symbol" (merged 2026-08-05) is in 7.1 (its port d20f192a in this repo is an ancestor of all four 7.1 gitHeads above) and not in 7.0.2 (2bd066d8 branches from typescript-go main at 52168999, 2026-07-08)
in a real service this breaks every SAP Cloud SDK call that passes a generated entity's request builder or link where the SDK takes the EntityBase form (new ODataBatchRequestBuilder(...), new BatchChangeSet(...), .select(SomeApi.schema.TO_X.select(...)), .filter(SomeApi.schema.TO_X.filter(...))): 41 errors in 26 files, all of them TS2345/TS2769 that 7.0.2 accepts
- 主要語言
- Go
- 星號
- 112k
- 分支
- 15.4k
- 平均合併
- 2 天 21 小時
- 30 天內合併 PR
- 126
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
microsoft/TypeScript 的其他 Issue
-
Won't Fix
難度 2/5 1-3 小時 新手友好度 62/100
microsoft/TypeScript#65107 · 1 則留言 ·
維護者通常 1 天內回覆
-
Native API: formatDiagnosticsWithColorAndContext drops related information without a file location可能已有人在做 @timurzvural 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 75/100
microsoft/TypeScript#65087 ·
維護者通常 1 天內回覆
-
TS7 LSP: documentHighlight returns nothing when the file path contains '@'可能重新可做 關聯的 PR 已關閉且未合併。 未關閉Bug
難度 2/5 1-3 小時 新手友好度 78/100
microsoft/TypeScript#64758 ·
維護者通常 1 天內回覆
-
Language server (tsc --lsp) exits with code 1 after `shutdown` and `exit`可能已有人在做 @rajnish-verma-22172 於 13 天前認領。 未關閉Bug
難度 2/5 1-3 小時 新手友好度 76/100
microsoft/TypeScript#64742 · 1 則留言 ·
維護者通常 1 天內回覆
-
Class names `eval` and `arguments` are not reported as invalid strict mode bindings可能已有人在做 @dmety 於 26 天前認領。 未關閉Bug
難度 2/5 1-3 小時 新手友好度 68/100
microsoft/TypeScript#64661 ·
維護者通常 1 天內回覆
查看 microsoft/TypeScript 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 84/100
維護者通常 1 天內回覆
-
cmd/ebitenmobile: multi-language bindings run the complete generator twice可能已有人在做 @kumagi 今天認領。 未關閉os:macos performance
難度 2/5 1-3 小時 新手友好度 82/100
hajimehoshi/ebiten#4011 · 1 則留言 ·
維護者通常 1 天內回覆
-
agent-butler-finding chore
難度 1/5 1 小時以內 新手友好度 78/100
jordansmall/spindrift#6318 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
Eyevinn/moqlivemock#166 ·
維護者通常 1 天內回覆