Skip to content

Commit b98089d

Browse files
committed
Update LKG
1 parent 73e2328 commit b98089d

File tree

7 files changed

+234
-42
lines changed

7 files changed

+234
-42
lines changed

lib/tsc.js

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,17 @@ var ts;
966966
};
967967
}
968968
ts.createCompilerDiagnostic = createCompilerDiagnostic;
969+
function createCompilerDiagnosticFromMessageChain(chain) {
970+
return {
971+
file: undefined,
972+
start: undefined,
973+
length: undefined,
974+
code: chain.code,
975+
category: chain.category,
976+
messageText: chain.next ? chain : chain.messageText
977+
};
978+
}
979+
ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain;
969980
function chainDiagnosticMessages(details, message) {
970981
var text = getLocaleSpecificMessage(message);
971982
if (arguments.length > 2) {
@@ -3041,6 +3052,7 @@ var ts;
30413052
Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" },
30423053
Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" },
30433054
Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" },
3055+
Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" },
30443056
};
30453057
})(ts || (ts = {}));
30463058
var ts;
@@ -20148,7 +20160,9 @@ var ts;
2014820160
else if (getObjectFlags(type) & 3 || type.flags & (16 | 16384)) {
2014920161
buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064, 0, nextFlags);
2015020162
}
20151-
else if (!(flags & 512) && ((getObjectFlags(type) & 16 && !type.target) || type.flags & 196608) && type.aliasSymbol &&
20163+
else if (!(flags & 512) &&
20164+
(getObjectFlags(type) & 16 && !type.target || type.flags & 196608) &&
20165+
type.aliasSymbol &&
2015220166
isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) {
2015320167
var typeArguments = type.aliasTypeArguments;
2015420168
writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags);
@@ -20257,7 +20271,7 @@ var ts;
2025720271
}
2025820272
else if (ts.contains(symbolStack, symbol)) {
2025920273
var typeAlias = getTypeAliasForTypeLiteral(type);
20260-
if (typeAlias) {
20274+
if (typeAlias && !type.target) {
2026120275
buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793064, 0, flags);
2026220276
}
2026320277
else {
@@ -48026,20 +48040,32 @@ var ts;
4802648040
if (emitFileName) {
4802748041
var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName);
4802848042
if (filesByName.contains(emitFilePath)) {
48029-
createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file);
48043+
if (options.noEmitOverwritenFiles && !options.out && !options.outDir && !options.outFile) {
48044+
blockEmittingOfFile(emitFileName);
48045+
}
48046+
else {
48047+
var chain_1;
48048+
if (!options.configFilePath) {
48049+
chain_1 = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig);
48050+
}
48051+
chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName);
48052+
blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain_1));
48053+
}
4803048054
}
4803148055
if (emitFilesSeen.contains(emitFilePath)) {
48032-
createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files);
48056+
blockEmittingOfFile(emitFileName, ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName));
4803348057
}
4803448058
else {
4803548059
emitFilesSeen.set(emitFilePath, true);
4803648060
}
4803748061
}
4803848062
}
4803948063
}
48040-
function createEmitBlockingDiagnostics(emitFileName, message) {
48064+
function blockEmittingOfFile(emitFileName, diag) {
4804148065
hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true);
48042-
programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName));
48066+
if (diag) {
48067+
programDiagnostics.add(diag);
48068+
}
4804348069
}
4804448070
}
4804548071
ts.createProgram = createProgram;

lib/tsserver.js

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,17 @@ var ts;
971971
};
972972
}
973973
ts.createCompilerDiagnostic = createCompilerDiagnostic;
974+
function createCompilerDiagnosticFromMessageChain(chain) {
975+
return {
976+
file: undefined,
977+
start: undefined,
978+
length: undefined,
979+
code: chain.code,
980+
category: chain.category,
981+
messageText: chain.next ? chain : chain.messageText
982+
};
983+
}
984+
ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain;
974985
function chainDiagnosticMessages(details, message) {
975986
var text = getLocaleSpecificMessage(message);
976987
if (arguments.length > 2) {
@@ -3046,6 +3057,7 @@ var ts;
30463057
Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" },
30473058
Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" },
30483059
Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" },
3060+
Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" },
30493061
};
30503062
})(ts || (ts = {}));
30513063
var ts;
@@ -21653,7 +21665,9 @@ var ts;
2165321665
else if (getObjectFlags(type) & 3 || type.flags & (16 | 16384)) {
2165421666
buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064, 0, nextFlags);
2165521667
}
21656-
else if (!(flags & 512) && ((getObjectFlags(type) & 16 && !type.target) || type.flags & 196608) && type.aliasSymbol &&
21668+
else if (!(flags & 512) &&
21669+
(getObjectFlags(type) & 16 && !type.target || type.flags & 196608) &&
21670+
type.aliasSymbol &&
2165721671
isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) {
2165821672
var typeArguments = type.aliasTypeArguments;
2165921673
writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags);
@@ -21762,7 +21776,7 @@ var ts;
2176221776
}
2176321777
else if (ts.contains(symbolStack, symbol)) {
2176421778
var typeAlias = getTypeAliasForTypeLiteral(type);
21765-
if (typeAlias) {
21779+
if (typeAlias && !type.target) {
2176621780
buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793064, 0, flags);
2176721781
}
2176821782
else {
@@ -49531,20 +49545,32 @@ var ts;
4953149545
if (emitFileName) {
4953249546
var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName);
4953349547
if (filesByName.contains(emitFilePath)) {
49534-
createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file);
49548+
if (options.noEmitOverwritenFiles && !options.out && !options.outDir && !options.outFile) {
49549+
blockEmittingOfFile(emitFileName);
49550+
}
49551+
else {
49552+
var chain_1;
49553+
if (!options.configFilePath) {
49554+
chain_1 = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig);
49555+
}
49556+
chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName);
49557+
blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain_1));
49558+
}
4953549559
}
4953649560
if (emitFilesSeen.contains(emitFilePath)) {
49537-
createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files);
49561+
blockEmittingOfFile(emitFileName, ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName));
4953849562
}
4953949563
else {
4954049564
emitFilesSeen.set(emitFilePath, true);
4954149565
}
4954249566
}
4954349567
}
4954449568
}
49545-
function createEmitBlockingDiagnostics(emitFileName, message) {
49569+
function blockEmittingOfFile(emitFileName, diag) {
4954649570
hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true);
49547-
programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName));
49571+
if (diag) {
49572+
programDiagnostics.add(diag);
49573+
}
4954849574
}
4954949575
}
4955049576
ts.createProgram = createProgram;
@@ -62510,6 +62536,9 @@ var ts;
6251062536
else if (hasExplicitListOfFiles) {
6251162537
this.compilerOptions.allowNonTsExtensions = true;
6251262538
}
62539+
if (this.projectKind === ProjectKind.Inferred) {
62540+
this.compilerOptions.noEmitOverwritenFiles = true;
62541+
}
6251362542
if (languageServiceEnabled) {
6251462543
this.enableLanguageService();
6251562544
}

lib/tsserverlibrary.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2924,6 +2924,7 @@ declare namespace ts {
29242924
moduleResolution?: ModuleResolutionKind;
29252925
newLine?: NewLineKind;
29262926
noEmit?: boolean;
2927+
noEmitOverwritenFiles?: boolean;
29272928
noEmitHelpers?: boolean;
29282929
noEmitOnError?: boolean;
29292930
noErrorTruncation?: boolean;
@@ -3445,6 +3446,7 @@ declare namespace ts {
34453446
function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic;
34463447
function formatMessage(_dummy: any, message: DiagnosticMessage): string;
34473448
function createCompilerDiagnostic(message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic;
3449+
function createCompilerDiagnosticFromMessageChain(chain: DiagnosticMessageChain): Diagnostic;
34483450
function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage, ...args: any[]): DiagnosticMessageChain;
34493451
function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain, tailChain: DiagnosticMessageChain): DiagnosticMessageChain;
34503452
function compareValues<T>(a: T, b: T): Comparison;
@@ -8272,6 +8274,12 @@ declare namespace ts {
82728274
key: string;
82738275
message: string;
82748276
};
8277+
Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: {
8278+
code: number;
8279+
category: DiagnosticCategory;
8280+
key: string;
8281+
message: string;
8282+
};
82758283
};
82768284
}
82778285
declare namespace ts {

lib/tsserverlibrary.js

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,17 @@ var ts;
971971
};
972972
}
973973
ts.createCompilerDiagnostic = createCompilerDiagnostic;
974+
function createCompilerDiagnosticFromMessageChain(chain) {
975+
return {
976+
file: undefined,
977+
start: undefined,
978+
length: undefined,
979+
code: chain.code,
980+
category: chain.category,
981+
messageText: chain.next ? chain : chain.messageText
982+
};
983+
}
984+
ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain;
974985
function chainDiagnosticMessages(details, message) {
975986
var text = getLocaleSpecificMessage(message);
976987
if (arguments.length > 2) {
@@ -3046,6 +3057,7 @@ var ts;
30463057
Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" },
30473058
Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" },
30483059
Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" },
3060+
Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" },
30493061
};
30503062
})(ts || (ts = {}));
30513063
var ts;
@@ -21653,7 +21665,9 @@ var ts;
2165321665
else if (getObjectFlags(type) & 3 || type.flags & (16 | 16384)) {
2165421666
buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064, 0, nextFlags);
2165521667
}
21656-
else if (!(flags & 512) && ((getObjectFlags(type) & 16 && !type.target) || type.flags & 196608) && type.aliasSymbol &&
21668+
else if (!(flags & 512) &&
21669+
(getObjectFlags(type) & 16 && !type.target || type.flags & 196608) &&
21670+
type.aliasSymbol &&
2165721671
isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) {
2165821672
var typeArguments = type.aliasTypeArguments;
2165921673
writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags);
@@ -21762,7 +21776,7 @@ var ts;
2176221776
}
2176321777
else if (ts.contains(symbolStack, symbol)) {
2176421778
var typeAlias = getTypeAliasForTypeLiteral(type);
21765-
if (typeAlias) {
21779+
if (typeAlias && !type.target) {
2176621780
buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793064, 0, flags);
2176721781
}
2176821782
else {
@@ -49531,20 +49545,32 @@ var ts;
4953149545
if (emitFileName) {
4953249546
var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName);
4953349547
if (filesByName.contains(emitFilePath)) {
49534-
createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file);
49548+
if (options.noEmitOverwritenFiles && !options.out && !options.outDir && !options.outFile) {
49549+
blockEmittingOfFile(emitFileName);
49550+
}
49551+
else {
49552+
var chain_1;
49553+
if (!options.configFilePath) {
49554+
chain_1 = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig);
49555+
}
49556+
chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName);
49557+
blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain_1));
49558+
}
4953549559
}
4953649560
if (emitFilesSeen.contains(emitFilePath)) {
49537-
createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files);
49561+
blockEmittingOfFile(emitFileName, ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName));
4953849562
}
4953949563
else {
4954049564
emitFilesSeen.set(emitFilePath, true);
4954149565
}
4954249566
}
4954349567
}
4954449568
}
49545-
function createEmitBlockingDiagnostics(emitFileName, message) {
49569+
function blockEmittingOfFile(emitFileName, diag) {
4954649570
hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true);
49547-
programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName));
49571+
if (diag) {
49572+
programDiagnostics.add(diag);
49573+
}
4954849574
}
4954949575
}
4955049576
ts.createProgram = createProgram;
@@ -62510,6 +62536,9 @@ var ts;
6251062536
else if (hasExplicitListOfFiles) {
6251162537
this.compilerOptions.allowNonTsExtensions = true;
6251262538
}
62539+
if (this.projectKind === ProjectKind.Inferred) {
62540+
this.compilerOptions.noEmitOverwritenFiles = true;
62541+
}
6251362542
if (languageServiceEnabled) {
6251462543
this.enableLanguageService();
6251562544
}

0 commit comments

Comments
 (0)