microsoft / microsoft/TypeScript

Expose "getNewLineCharacter" function

Open
#29,581 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Domain: API In Discussion Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

Suggestion

Make ts.getNewLineCharacter public

Use Cases

This is useful if developers create their own FormatDiagnosticsHost, but don't want to implement the logic to determine the newLine string based on the newLine compiler option.

Examples

    const formatHost: ts.FormatDiagnosticsHost = {
      getCurrentDirectory: () => projectDir || ts.sys.getCurrentDirectory(),
      getCanonicalFileName: fileName => fileName,
      getNewLine: () => ts.getNewLineCharacter(formatOptions)
    };

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the existing ts.getNewLineCharacter implementation and its public compiler API declarations. Read how FormatDiagnosticsHost and the newLine compiler option are currently exposed, then make the function publicly callable and verify that the example use case can obtain the selected newline character.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.