Skip to content

Commit daf14b1

Browse files
committed
Change default compiler options
* Default newline is now lf instead of os-specific * forceConsistentCasingInFilenames now defaults to true
1 parent 18794c7 commit daf14b1

File tree

8 files changed

+16
-19
lines changed

8 files changed

+16
-19
lines changed

src/compiler/commandLineParser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
12751275
paramType: Diagnostics.NEWLINE,
12761276
category: Diagnostics.Emit,
12771277
description: Diagnostics.Set_the_newline_character_for_emitting_files,
1278-
defaultValueDescription: Diagnostics.Platform_specific
1278+
defaultValueDescription: "lf"
12791279
},
12801280
{
12811281
name: "noErrorTruncation",
@@ -1451,7 +1451,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
14511451
affectsModuleResolution: true,
14521452
category: Diagnostics.Interop_Constraints,
14531453
description: Diagnostics.Ensure_that_casing_is_correct_in_imports,
1454-
defaultValueDescription: false,
1454+
defaultValueDescription: true,
14551455
},
14561456
{
14571457
name: "maxNodeModuleJsDepth",

src/compiler/emitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFi
738738
const sourceMapDataList: SourceMapEmitResult[] | undefined = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined;
739739
const emittedFilesList: string[] | undefined = compilerOptions.listEmittedFiles ? [] : undefined;
740740
const emitterDiagnostics = createDiagnosticCollection();
741-
const newLine = getNewLineCharacter(compilerOptions, () => host.getNewLine());
741+
const newLine = getNewLineCharacter(compilerOptions);
742742
const writer = createTextWriter(newLine);
743743
const { enter, exit } = performance.createTimer("printTime", "beforePrint", "afterPrint");
744744
let bundleBuildInfo: BundleBuildInfo | undefined;

src/compiler/program.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ export function createCompilerHostWorker(options: CompilerOptions, setParentNode
456456
return getDirectoryPath(normalizePath(system.getExecutingFilePath()));
457457
}
458458

459-
const newLine = getNewLineCharacter(options, () => system.newLine);
459+
const newLine = getNewLineCharacter(options);
460460
const realpath = system.realpath && ((path: string) => system.realpath!(path));
461461
const compilerHost: CompilerHost = {
462462
getSourceFile: createGetSourceFile(fileName => compilerHost.readFile(fileName), () => options, setParentNodes),
@@ -3418,7 +3418,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
34183418
addFileIncludeReason(file || undefined, reason);
34193419
// try to check if we've already seen this file but with a different casing in path
34203420
// NOTE: this only makes sense for case-insensitive file systems, and only on files which are not redirected
3421-
if (file && options.forceConsistentCasingInFileNames) {
3421+
if (file && options.forceConsistentCasingInFileNames !== false) {
34223422
const checkedName = file.fileName;
34233423
const isRedirect = toPath(checkedName) !== toPath(fileName);
34243424
if (isRedirect) {

src/compiler/utilities.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,6 @@ import {
482482
SymbolTable,
483483
SyntaxKind,
484484
SyntaxList,
485-
sys,
486485
TaggedTemplateExpression,
487486
TemplateLiteral,
488487
TemplateLiteralLikeNode,
@@ -6651,14 +6650,14 @@ export function directoryProbablyExists(directoryName: string, host: { directory
66516650
const carriageReturnLineFeed = "\r\n";
66526651
const lineFeed = "\n";
66536652
/** @internal */
6654-
export function getNewLineCharacter(options: CompilerOptions | PrinterOptions, getNewLine?: () => string): string {
6653+
export function getNewLineCharacter(options: CompilerOptions | PrinterOptions): string {
66556654
switch (options.newLine) {
66566655
case NewLineKind.CarriageReturnLineFeed:
66576656
return carriageReturnLineFeed;
66586657
case NewLineKind.LineFeed:
6659-
return lineFeed;
6658+
case undefined:
6659+
return lineFeed;
66606660
}
6661-
return getNewLine ? getNewLine() : sys ? sys.newLine : carriageReturnLineFeed;
66626661
}
66636662

66646663
/**

src/compiler/watch.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,6 @@ export function createWatchFactory<Y = undefined>(host: WatchFactoryHost & { tra
745745
/** @internal */
746746
export function createCompilerHostFromProgramHost(host: ProgramHost<any>, getCompilerOptions: () => CompilerOptions, directoryStructureHost: DirectoryStructureHost = host): CompilerHost {
747747
const useCaseSensitiveFileNames = host.useCaseSensitiveFileNames();
748-
const hostGetNewLine = memoize(() => host.getNewLine());
749748
const compilerHost: CompilerHost = {
750749
getSourceFile: createGetSourceFile(
751750
(fileName, encoding) => !encoding ? compilerHost.readFile(fileName) : host.readFile(fileName, encoding),
@@ -762,7 +761,7 @@ export function createCompilerHostFromProgramHost(host: ProgramHost<any>, getCom
762761
getCurrentDirectory: memoize(() => host.getCurrentDirectory()),
763762
useCaseSensitiveFileNames: () => useCaseSensitiveFileNames,
764763
getCanonicalFileName: createGetCanonicalFileName(useCaseSensitiveFileNames),
765-
getNewLine: () => getNewLineCharacter(getCompilerOptions(), hostGetNewLine),
764+
getNewLine: () => getNewLineCharacter(getCompilerOptions()),
766765
fileExists: f => host.fileExists(f),
767766
readFile: f => host.readFile(f),
768767
trace: maybeBind(host, host.trace),
@@ -867,7 +866,7 @@ function createWatchCompilerHost<T extends BuilderProgram = EmitAndSemanticDiagn
867866
copyProperties(result, createWatchHost(system, reportWatchStatus));
868867
result.afterProgramCreate = builderProgram => {
869868
const compilerOptions = builderProgram.getCompilerOptions();
870-
const newLine = getNewLineCharacter(compilerOptions, () => system.newLine);
869+
const newLine = getNewLineCharacter(compilerOptions);
871870

872871
emitFilesAndReportErrors(
873872
builderProgram,

src/compiler/watchPublic.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ export function createWatchProgram<T extends BuilderProgram>(host: WatchCompiler
441441
}
442442
reportWatchDiagnostic(Diagnostics.Starting_compilation_in_watch_mode);
443443
if (configFileName && !host.configFileParsingResult) {
444-
newLine = getNewLineCharacter(optionsToExtendForConfigFile, () => host.getNewLine());
444+
newLine = getNewLineCharacter(optionsToExtendForConfigFile);
445445
Debug.assert(!rootFileNames);
446446
parseConfigFile();
447447
newLine = updateNewLine();
@@ -668,7 +668,7 @@ export function createWatchProgram<T extends BuilderProgram>(host: WatchCompiler
668668
}
669669

670670
function updateNewLine() {
671-
return getNewLineCharacter(compilerOptions || optionsToExtendForConfigFile, () => host.getNewLine());
671+
return getNewLineCharacter(compilerOptions || optionsToExtendForConfigFile);
672672
}
673673

674674
function toPath(fileName: string) {

src/services/completions.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ import {
262262
LiteralTypeNode,
263263
map,
264264
mapDefined,
265-
maybeBind,
266265
MemberOverrideStatus,
267266
memoize,
268267
memoizeOne,
@@ -1066,7 +1065,7 @@ function getExhaustiveCaseSnippets(
10661065
}
10671066

10681067
const newClauses = map(elements, element => factory.createCaseClause(element, []));
1069-
const newLineChar = getNewLineCharacter(options, maybeBind(host, host.getNewLine));
1068+
const newLineChar = getNewLineCharacter(options);
10701069
const printer = createSnippetPrinter({
10711070
removeComments: true,
10721071
module: options.module,
@@ -1569,7 +1568,7 @@ function getEntryForMemberCompletion(
15691568
module: options.module,
15701569
target: options.target,
15711570
omitTrailingSemicolon: false,
1572-
newLine: getNewLineKind(getNewLineCharacter(options, maybeBind(host, host.getNewLine))),
1571+
newLine: getNewLineKind(getNewLineCharacter(options)),
15731572
});
15741573
const importAdder = codefix.createImportAdder(sourceFile, program, preferences, host);
15751574

@@ -1735,7 +1734,7 @@ function getEntryForObjectLiteralMethodCompletion(
17351734
module: options.module,
17361735
target: options.target,
17371736
omitTrailingSemicolon: false,
1738-
newLine: getNewLineKind(getNewLineCharacter(options, maybeBind(host, host.getNewLine))),
1737+
newLine: getNewLineKind(getNewLineCharacter(options)),
17391738
});
17401739
if (formatContext) {
17411740
insertText = printer.printAndFormatSnippetList(ListFormat.CommaDelimited | ListFormat.AllowTrailingComma, factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext);

src/services/services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ export function createLanguageService(
16431643
getCancellationToken: () => cancellationToken,
16441644
getCanonicalFileName,
16451645
useCaseSensitiveFileNames: () => useCaseSensitiveFileNames,
1646-
getNewLine: () => getNewLineCharacter(newSettings, () => getNewLineOrDefaultFromHost(host)),
1646+
getNewLine: () => getNewLineCharacter(newSettings),
16471647
getDefaultLibFileName: options => host.getDefaultLibFileName(options),
16481648
writeFile: noop,
16491649
getCurrentDirectory: () => currentDirectory,

0 commit comments

Comments
 (0)