Microsoft/TypeScript

Document and/or deprecate Node's getFullStart() vs. pos?

Open

#57,053 建立於 2024年1月14日

在 GitHub 查看
 (1 留言) (0 反應) (0 負責人)TypeScript (6,726 fork)batch import
Help WantedInfrastructure

倉庫指標

Star
 (48,455 star)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 9 個 PR)

描述

Acknowledgement

  • I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.

Comment

Coming over from https://github.com/typescript-eslint/typescript-eslint/issues/8227 -> https://discord.com/channels/508357248330760243/640177429775777792/1194002057858916483: it looks like ts.Node objects have both a pos: number property and a getFullStart(): number method that directly returns this.pos:

https://github.com/microsoft/TypeScript/blob/02f9ddf55d27716c0306ec6561baf80d42744fed/src/services/services.ts#L564-L566

Doing some quick Find all references from the interfaces' definitions in VS Code:

  • Node's getFullStart() has 25 results
  • ReadonlyTextRanges readonly pos has 407 results

I looked through the GitHub repo and code history but couldn't find anything justifying why both exist. My hunch is maybe that #9529 which added getFullStart() predates TS 2.0's readonly (TS 2.0 release notes > readonly)?

Given that getFullStart() incurs an extra function call, is there any reason beyond backwards compatibility to keep it around? If not, would the team be open to marking it as @deprecated in JSDoc to reduce ambiguity?

貢獻者指南