惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Last Watchdog
The Last Watchdog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
GbyAI
GbyAI
Y
Y Combinator Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
博客园_首页
小众软件
小众软件
I
InfoQ
J
Java Code Geeks
月光博客
月光博客
S
Secure Thoughts
Microsoft Security Blog
Microsoft Security Blog
V
Visual Studio Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Stack Overflow Blog
Stack Overflow Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
N
News and Events Feed by Topic
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Cloudflare Blog
T
Threat Research - Cisco Blogs
A
About on SuperTechFans
H
Help Net Security
MongoDB | Blog
MongoDB | Blog
博客园 - 聂微东
人人都是产品经理
人人都是产品经理
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Latest news
Latest news
G
GRAHAM CLULEY
IT之家
IT之家
C
Cisco Blogs
Last Week in AI
Last Week in AI
Engineering at Meta
Engineering at Meta
L
LangChain Blog
The Register - Security
The Register - Security
SecWiki News
SecWiki News
M
MIT News - Artificial intelligence
NISL@THU
NISL@THU
T
Tenable Blog
博客园 - Franky
美团技术团队
I
Intezer
U
Unit 42
雷峰网
雷峰网
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
SegmentFault 最新的问题
C
Cyber Attacks, Cyber Crime and Cyber Security

TypeScript

ts 生态有没有开源的简单的 kv 配置管理项目 - V2EX 你们是怎么学习 typescript 的? - V2EX 用 Go 移植的 TypeScript 7 要来了 - V2EX TypeScript5.9,仿佛走出草原来到了现代社会 - V2EX Typescript 有没有能对接 AI 的知识库或者文档?能处理稍微复杂点的类型 - V2EX ts 有没有直接能查看最终类型的方法 - V2EX TypeScript Native 预览版发布了 - V2EX 关于 TypeScript 装饰器和接口的问题,请教一下各位 - V2EX 你们 typescript 用自带枚举还是字符串枚举,感觉字符串枚举类型用起来有点不可靠啊 - V2EX effect-ts - V2EX typescript 达人乱入 - V2EX TypeScript 宣布原生移植计划,性能将提升 10 倍? - V2EX #笔记#更好的 ts 重载声明方法 - V2EX 使用 satisfies 实现穷举类型保护 - V2EX 请教一个 TS 问题,不知能否实现 - V2EX 装饰器能不能装饰类的所有方法 - V2EX TypeSciprt 类型推断,如何进一步收窄类型? - V2EX TypeScript 项目打包发布到 npm,如何给方法和接口添加 dts TypeScript 类型推导真强大。 - V2EX 为啥下面这段代码 TS 不报错 - V2EX ts 类型约束+请求参数校验+自动生成 openapi/swagger 文档,这三者目前有整合为一体的最佳实践吗 - V2EX TypeScript 能不能别这么古怪,这行为什么会报错呢? - V2EX 怎么每次碰到想不通的代码行都出在 TypeScript😢 这行到底哪里有问题? - V2EX 低估了 typescript 的难度 - V2EX 前端写 nestjs 后端,用 TypeORM 时感到非常困惑,不知道是不是我的理解有问题 - V2EX 我列举了市面上最好的几个 TypeScript 教程, 想深入学习 TypeScript 的同学以后不用走弯路了 - V2EX 这样的函数类型定义在 ts 里面叫什么? - V2EX typescript 如何忽略泛型参数啊? - V2EX TypeScript 现在的应用场景 - V2EX ==TypeScript 写的 npm 包可以用 javascript 使用包的函数吗 - V2EX react 如何优雅的实现批量删除+二次确认 - V2EX TypeScript 怎么 wrap 一个函数并修改一下返回值? - V2EX 想请教个 TypeScript 抽象类继承父类的问题。 - V2EX vscode 纯 js 项目有类型推断和成员变量提示,但是如果 ts 混用的话, js 导入就全变成 any 了,请问有办法解决吗 这个项目这样定义 Typescript 类型和使用,学到了,有几个问题? - V2EX 请教一个 Typescript 的问题 - V2EX 这种的类型是不是实现不了(TypeScript) - V2EX 问题一个 typescript 类型包裹问题 - V2EX 遇到了极其诡异的不符合进入 if 条件的要求但是还是进入了 - V2EX typescript 的类型处理 - V2EX 想问问大家 TypeScript 中关于 null 处理的方式 - V2EX 有没有声明 typescript 类型的好办法以及前端样式的健壮性问题 - V2EX typescript 类型断言问题 - V2EX TypeScript 中类型编程简介 - V2EX [求助] 类型 { K:V } --> { "type": K , "conf": V } 且约束 - V2EX 大佬们, vscode 开发 ts,这个地方的提示,怎么修改成中文啊 - V2EX TypeScript 中「类型定义的命名空间」使用 - V2EX 有没有办法把 ts 的 error 报错改成 warning - V2EX [求助] 函数中使用泛型缩小参数类型 - V2EX
typescript 如何返回一个动态对象类型 - V2EX
tmkook · 2025-06-20 · via TypeScript

这是一个创建于 359 天前的主题,其中的信息可能已经有所发展或是发生改变。

class a extends schema {
    fun1 () => 1
}
class b extends schema{
    fun2 () => 2
}

const objs = {
    a:new a
    b:new b
}

function find(key) : any{
    return objs[key]
}

这个 objs 很多个 obj 他们都继承自同一个父类,有什么办法在调用 find 返回的对象能保持代码提示吗?

let obj = find('a')
obj.fun1 //代码提示

第 1 条附言  ·  2025 年 6 月 20 日

class Schema{
   protected json: Record<string, any> = {}

  attr(key:string,value:any){
     this.json[key] = value
  }

   find(id:string){
    return finder(this.json, id)
  }
}


function finder(obj: Record<string, any>, id: string) {
 // 递归查找 id 对应的 obj 
 // obj 都是继承自 Schema 的
 return obj
}


let a = new Schema
a.find('b')

json 里的内容是动态,似乎无法实现,试了好几个AI改出来的都不对。

RomeoHong

1

RomeoHong      2025 年 6 月 20 日   ❤️ 2

type Objs = typeof objs;
function find<K extends keyof Objs>(key: K): Objs[K] {
return objs[key]
}

bjzhou1990

3

bjzhou1990      2025 年 6 月 20 日   ❤️ 1

function find<T extends Schema>(key: string): T {
return objs[key]
}

const c = find('a')
c.attr('a', 'b')

不知道是不是你要的

nebnyp410404

5

nebnyp410404      2025 年 6 月 21 日

class schema {
func: Function
}

class a extends schema {
fun1: () => 1
}
class b extends schema{
fun2: () => 2
}

const objs = {
a:new a,
b:new b
}

type Key = keyof typeof objs;

function find<T extends Key>(key: T): typeof objs[T] {
return objs[key];
}

const cc = find('a')