Make incomplete scanner APIs internal #44250
Comments
@sheetalkamat @sandersn any thoughts on this one? |
I'm not familiar with these functions. If I'm reading your proposal correctly, I think you want to remove the properties on |
I dont understand the suggestion here at all.. |
Exactly. Let me explain about two functions. SourceFile is declared here: TypeScript/src/services/types.ts Lines 90 to 104 in 3d24b85 These methods are easy to use (just call them). And There are also two exported functions in scanner.ts: TypeScript/src/compiler/scanner.ts Lines 387 to 394 in 5fde871 TypeScript/src/compiler/scanner.ts Lines 470 to 472 in 5fde871 Both functions take ts.getPositionOfLineAndCharacter({
getLineAndCharacterOfPosition: () => /* ... */,
}, line, number); And I found a construction case in this project: TypeScript/src/services/textChanges.ts Line 1025 in db01e84 My above code is buildable despite of lacking TypeScript/lib/typescript.d.ts Lines 5339 to 5341 in 5fde871 But as I wrote in description, Two functions (not methods of SourceFile) use Should we expose only
|
Thank you for explaination.. now i see what you mean.. The actual definition of SourceFileLike in compiler is internal but not in services so public one doesnt have the right definition. Got it |
I think we should make SourceFileLike in |
Thank you for your reply. Let me write my thoughts. SourceFileLike in compiler\types.ts is here: TypeScript/src/compiler/types.ts Lines 3460 to 3469 in 9aa50d6
Impact to internal codes
Impact to external codes
|
And I'll try this fix. |
Suggestion
My suggestion meets these guidelines:
ts.getPositionOfLineAndCharacter
should be marked with/* @internal */
ts.getLineAndCharacterOfPosition
should be marked with/* @internal */
These methods take an argument of
SourceFileLike
at first, and its type is defined as:in
src/compiler/types.ts
and also defined:in
src/services/types.ts
. so, required implementation ofSourceFileLike
in public is onlygetLineAndCharacterOfPosition
. But two exposed methods are uses all internal-marked members in actual (occurs runtime error).After this changes, These methods in
SourceFile
is still available:The text was updated successfully, but these errors were encountered: