🔎 搜索词
数组类型定义崩溃
🕗 版本与回归信息
- 这是一次崩溃
⏯ Playground链接
https://www.typescriptlang.org/dev/bug-workbench/?noLib=true#code/PTAEAEDsHsBkEsBGAuUAXATgVwKYCg0BPABx1AEEMMBDQgHgBUA+UAXlAYG0BdAbjyA
💻 代码
// @noLib: true
type Array<T> = T[];
🙁 实际行为
Typescript崩溃:
createDeferredTypeReference@https://typescript.azureedge.net/cdn/5.4.0-dev.20240110/monaco/dev/vs/language/typescript/tsWorker.js:52280:42
getTypeFromArrayOrTupleTypeNode@https://typescript.azureedge.net/cdn/5.4.0-dev.20240110/monaco/dev/vs/language/typescript/tsWorker.js:52908:93
getTypeFromTypeNodeWorker@https://typescript.azureedge.net/cdn/5.4.0-dev.20240110/monaco/dev/vs/language/typescript/tsWorker.js:54875:20
getTypeFromTypeNode@https://typescript.azureedge.net/cdn/5.4.0-dev.20240110/monaco/dev/vs/language/typescript/tsWorker.js:54828:45
getDeclaredTypeOfTypeAlias@https://typescript.azureedge.net/cdn/5.4.0-dev.20240110/monaco/dev/vs/language/typescript/tsWorker.js:49869:33
tryGetDeclaredTypeOfSymbol@https://typescript.azureedge.net/cdn/5.4.0-dev.20240110/monaco/dev/vs/language/typescript/tsWorker.js:49955:18
getDeclaredTypeOfSymbol@https://typescript.azureedge.net/cdn/5.4.0-dev.20240110/monaco/dev/vs/language/typescript/tsWorker.js:49948:16
getTypeOfGlobalSymbol@https://typescript.azureedge.net/cdn/5.4.0-dev.20240110/monaco/dev/vs/language/typescript/tsWorker.js:52644:45
getGlobalType@https://typescript.azureedge.net/cdn/5.4.0-dev.20240110/monaco/dev/vs/language/typescript/tsWorker.js:52678:42
initializeTypeChecker@https://typescript.azureedge.net/cdn/5.4.0-dev.20240110/monaco/dev/vs/language/typescript/tsWorker.js:75719:27
createTypeChecker@https://typescript.azureedge.net/cdn/5.4.0-dev.20240110/monaco/dev/vs/language/typescript/tsWorker.js:42674:7
getTypeChecker@https://typescript.azureedge.net/cdn/5.4.0-dev.20240110/monaco/dev/vs/language/typescript/tsWorker.js:101959:46
synchronizeHostDataWorker@https://typescript.azureedge.net/cdn/5.4.0-dev.20240110/monaco/dev/vs/language/typescript/tsWorker.js:121935:17
synchronizeHostData@https://typescript.azureedge.net/cdn/5.4.0-dev.20240110/monaco/dev/vs/language/typescript/tsWorker.js:121830:11
getProgram@https://typescript.azureedge.net/cdn/5.4.0-dev.20240110/monaco/dev/vs/language/typescript/tsWorker.js:121997:9
updateFile@https://www.typescriptlang.org/17821066377c4486a980330106160c805ea5b4a9-5466acbcf54af90f679c.js:1:25348
G@https://www.typescriptlang.org/17821066377c4486a980330106160c805ea5b4a9-5466acbcf54af90f679c.js:1:17599
F@https://www.typescriptlang.org/17821066377c4486a980330106160c805ea5b4a9-5466acbcf54af90f679c.js:1:17638
A@https://www.typescriptlang.org/component---src-pages-dev-bug-workbench-tsx-6a9bdea3e00be7d97087.js:1:40663
9796/M/
🙂 预期行为
我期望看到一个错误信息。
关于问题的附加信息
- 无响应*
5条答案
按热度按时间qybjjes11#
为了澄清,这不会起作用。
xmjla07d2#
为了澄清,这不会起作用。我知道。我将重现示例从类似于
type Array<T> = T[] & { push: (t: T) => number }
(也是错误的)的东西减少了。我希望这段代码会给出一个关于循环类型引用的错误,就像我写的type Array<T> = Array<T>
一样。fcg9iug33#
似乎在这次崩溃之前发生了内部故障。这不是我对
Array
类型的特定定义有问题,而是使用类型别名来定义Array
本身:Workbench Repro
lb3vh1jj4#
你好,我是 Repro bot 。我可以协助缩小范围并跟踪编译器错误!此评论反映了当前运行在夜间 TypeScript 的重现情况。
@rotu 的评论
❌ 失败:-
Type '{}' does not satisfy the expected type '{ [i: number]: any; }'. Index signature for type 'number' is missing in type '{}'.
Type '{}' does not satisfy the expected type 'Array'. Index signature for type 'number' is missing in type '{}'.
历史信息
| 版本 | 重现输出 | 时间 |
| ------------ | ------------ | ------------ |
| 5.0.2 | ❌ 失败:-*
Type '{}' does not satisfy the expected type '{ [i: number]: any; }'. Index signature for type 'number' is missing in type '{}'.
*Type '{}' does not satisfy the expected type 'Array'. Index signature for type 'number' is missing in type '{}'.
| || 4.9.3, 5.1.3, 5.2.2, 5.3.2 | ❌ 失败:-*
Type '{}' does not satisfy the expected type '{ [i: number]: any; }'. Index signature for type 'number' is missing in type '{}'.
*Type '{}' does not satisfy the expected type 'Array'. Index signature for type 'number' is missing in type '{}'.
| ⚠️ 更慢 |yvgpqqbh5#
看起来在这次崩溃之前发生了内部故障。这不是我对
Array
类型的特定定义有问题,而是使用类型别名来定义Array
本身已将此问题移动到独立问题 #57564