-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptGood First IssueWell scoped, documented and has the green lightWell scoped, documented and has the green lightHelp WantedYou can do thisYou can do thisIn DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
Suggestion
π Search Terms
- scanner + label:API
- SourceFileLike
- getPositionOfLineAndCharacter
- getLineAndCharacterOfPosition
β Viability Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
β Suggestion
ts.getPositionOfLineAndCharactershould be marked with/* @internal */ts.getLineAndCharacterOfPositionshould be marked with/* @internal */
These methods take an argument of SourceFileLike at first, and its type is defined as:
/* @internal */
/**
* Subset of properties from SourceFile that are used in multiple utility functions
*/
export interface SourceFileLike {
readonly text: string;
lineMap?: readonly number[];
/* @internal */
getPositionOfLineAndCharacter?(line: number, character: number, allowEdits?: true): number;
}in src/compiler/types.ts and also defined:
export interface SourceFileLike {
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
}in src/services/types.ts. so, required implementation of SourceFileLike in public is only getLineAndCharacterOfPosition. But two exposed methods are uses all internal-marked members in actual (occurs runtime error).
π» Use Cases
After this changes, These methods in SourceFile is still available:
- getLineAndCharacterOfPosition
- getPositionOfLineAndCharacter
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptGood First IssueWell scoped, documented and has the green lightWell scoped, documented and has the green lightHelp WantedYou can do thisYou can do thisIn DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript