mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 11:35:42 -06:00
Update LKG
This commit is contained in:
parent
73e2328acb
commit
b98089dc53
38
lib/tsc.js
38
lib/tsc.js
@ -966,6 +966,17 @@ var ts;
|
||||
};
|
||||
}
|
||||
ts.createCompilerDiagnostic = createCompilerDiagnostic;
|
||||
function createCompilerDiagnosticFromMessageChain(chain) {
|
||||
return {
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
code: chain.code,
|
||||
category: chain.category,
|
||||
messageText: chain.next ? chain : chain.messageText
|
||||
};
|
||||
}
|
||||
ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain;
|
||||
function chainDiagnosticMessages(details, message) {
|
||||
var text = getLocaleSpecificMessage(message);
|
||||
if (arguments.length > 2) {
|
||||
@ -3041,6 +3052,7 @@ var ts;
|
||||
Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" },
|
||||
Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" },
|
||||
Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" },
|
||||
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" },
|
||||
};
|
||||
})(ts || (ts = {}));
|
||||
var ts;
|
||||
@ -20148,7 +20160,9 @@ var ts;
|
||||
else if (getObjectFlags(type) & 3 || type.flags & (16 | 16384)) {
|
||||
buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064, 0, nextFlags);
|
||||
}
|
||||
else if (!(flags & 512) && ((getObjectFlags(type) & 16 && !type.target) || type.flags & 196608) && type.aliasSymbol &&
|
||||
else if (!(flags & 512) &&
|
||||
(getObjectFlags(type) & 16 && !type.target || type.flags & 196608) &&
|
||||
type.aliasSymbol &&
|
||||
isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) {
|
||||
var typeArguments = type.aliasTypeArguments;
|
||||
writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags);
|
||||
@ -20257,7 +20271,7 @@ var ts;
|
||||
}
|
||||
else if (ts.contains(symbolStack, symbol)) {
|
||||
var typeAlias = getTypeAliasForTypeLiteral(type);
|
||||
if (typeAlias) {
|
||||
if (typeAlias && !type.target) {
|
||||
buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793064, 0, flags);
|
||||
}
|
||||
else {
|
||||
@ -48026,10 +48040,20 @@ var ts;
|
||||
if (emitFileName) {
|
||||
var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName);
|
||||
if (filesByName.contains(emitFilePath)) {
|
||||
createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file);
|
||||
if (options.noEmitOverwritenFiles && !options.out && !options.outDir && !options.outFile) {
|
||||
blockEmittingOfFile(emitFileName);
|
||||
}
|
||||
else {
|
||||
var chain_1;
|
||||
if (!options.configFilePath) {
|
||||
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);
|
||||
}
|
||||
chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName);
|
||||
blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain_1));
|
||||
}
|
||||
}
|
||||
if (emitFilesSeen.contains(emitFilePath)) {
|
||||
createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files);
|
||||
blockEmittingOfFile(emitFileName, ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName));
|
||||
}
|
||||
else {
|
||||
emitFilesSeen.set(emitFilePath, true);
|
||||
@ -48037,9 +48061,11 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
function createEmitBlockingDiagnostics(emitFileName, message) {
|
||||
function blockEmittingOfFile(emitFileName, diag) {
|
||||
hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true);
|
||||
programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName));
|
||||
if (diag) {
|
||||
programDiagnostics.add(diag);
|
||||
}
|
||||
}
|
||||
}
|
||||
ts.createProgram = createProgram;
|
||||
|
||||
@ -971,6 +971,17 @@ var ts;
|
||||
};
|
||||
}
|
||||
ts.createCompilerDiagnostic = createCompilerDiagnostic;
|
||||
function createCompilerDiagnosticFromMessageChain(chain) {
|
||||
return {
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
code: chain.code,
|
||||
category: chain.category,
|
||||
messageText: chain.next ? chain : chain.messageText
|
||||
};
|
||||
}
|
||||
ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain;
|
||||
function chainDiagnosticMessages(details, message) {
|
||||
var text = getLocaleSpecificMessage(message);
|
||||
if (arguments.length > 2) {
|
||||
@ -3046,6 +3057,7 @@ var ts;
|
||||
Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" },
|
||||
Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" },
|
||||
Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" },
|
||||
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" },
|
||||
};
|
||||
})(ts || (ts = {}));
|
||||
var ts;
|
||||
@ -21653,7 +21665,9 @@ var ts;
|
||||
else if (getObjectFlags(type) & 3 || type.flags & (16 | 16384)) {
|
||||
buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064, 0, nextFlags);
|
||||
}
|
||||
else if (!(flags & 512) && ((getObjectFlags(type) & 16 && !type.target) || type.flags & 196608) && type.aliasSymbol &&
|
||||
else if (!(flags & 512) &&
|
||||
(getObjectFlags(type) & 16 && !type.target || type.flags & 196608) &&
|
||||
type.aliasSymbol &&
|
||||
isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) {
|
||||
var typeArguments = type.aliasTypeArguments;
|
||||
writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags);
|
||||
@ -21762,7 +21776,7 @@ var ts;
|
||||
}
|
||||
else if (ts.contains(symbolStack, symbol)) {
|
||||
var typeAlias = getTypeAliasForTypeLiteral(type);
|
||||
if (typeAlias) {
|
||||
if (typeAlias && !type.target) {
|
||||
buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793064, 0, flags);
|
||||
}
|
||||
else {
|
||||
@ -49531,10 +49545,20 @@ var ts;
|
||||
if (emitFileName) {
|
||||
var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName);
|
||||
if (filesByName.contains(emitFilePath)) {
|
||||
createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file);
|
||||
if (options.noEmitOverwritenFiles && !options.out && !options.outDir && !options.outFile) {
|
||||
blockEmittingOfFile(emitFileName);
|
||||
}
|
||||
else {
|
||||
var chain_1;
|
||||
if (!options.configFilePath) {
|
||||
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);
|
||||
}
|
||||
chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName);
|
||||
blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain_1));
|
||||
}
|
||||
}
|
||||
if (emitFilesSeen.contains(emitFilePath)) {
|
||||
createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files);
|
||||
blockEmittingOfFile(emitFileName, ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName));
|
||||
}
|
||||
else {
|
||||
emitFilesSeen.set(emitFilePath, true);
|
||||
@ -49542,9 +49566,11 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
function createEmitBlockingDiagnostics(emitFileName, message) {
|
||||
function blockEmittingOfFile(emitFileName, diag) {
|
||||
hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true);
|
||||
programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName));
|
||||
if (diag) {
|
||||
programDiagnostics.add(diag);
|
||||
}
|
||||
}
|
||||
}
|
||||
ts.createProgram = createProgram;
|
||||
@ -62510,6 +62536,9 @@ var ts;
|
||||
else if (hasExplicitListOfFiles) {
|
||||
this.compilerOptions.allowNonTsExtensions = true;
|
||||
}
|
||||
if (this.projectKind === ProjectKind.Inferred) {
|
||||
this.compilerOptions.noEmitOverwritenFiles = true;
|
||||
}
|
||||
if (languageServiceEnabled) {
|
||||
this.enableLanguageService();
|
||||
}
|
||||
|
||||
8
lib/tsserverlibrary.d.ts
vendored
8
lib/tsserverlibrary.d.ts
vendored
@ -2924,6 +2924,7 @@ declare namespace ts {
|
||||
moduleResolution?: ModuleResolutionKind;
|
||||
newLine?: NewLineKind;
|
||||
noEmit?: boolean;
|
||||
noEmitOverwritenFiles?: boolean;
|
||||
noEmitHelpers?: boolean;
|
||||
noEmitOnError?: boolean;
|
||||
noErrorTruncation?: boolean;
|
||||
@ -3445,6 +3446,7 @@ declare namespace ts {
|
||||
function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic;
|
||||
function formatMessage(_dummy: any, message: DiagnosticMessage): string;
|
||||
function createCompilerDiagnostic(message: DiagnosticMessage, ...args: (string | number)[]): Diagnostic;
|
||||
function createCompilerDiagnosticFromMessageChain(chain: DiagnosticMessageChain): Diagnostic;
|
||||
function chainDiagnosticMessages(details: DiagnosticMessageChain, message: DiagnosticMessage, ...args: any[]): DiagnosticMessageChain;
|
||||
function concatenateDiagnosticMessageChains(headChain: DiagnosticMessageChain, tailChain: DiagnosticMessageChain): DiagnosticMessageChain;
|
||||
function compareValues<T>(a: T, b: T): Comparison;
|
||||
@ -8272,6 +8274,12 @@ declare namespace ts {
|
||||
key: string;
|
||||
message: string;
|
||||
};
|
||||
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: number;
|
||||
category: DiagnosticCategory;
|
||||
key: string;
|
||||
message: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
declare namespace ts {
|
||||
|
||||
@ -971,6 +971,17 @@ var ts;
|
||||
};
|
||||
}
|
||||
ts.createCompilerDiagnostic = createCompilerDiagnostic;
|
||||
function createCompilerDiagnosticFromMessageChain(chain) {
|
||||
return {
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
code: chain.code,
|
||||
category: chain.category,
|
||||
messageText: chain.next ? chain : chain.messageText
|
||||
};
|
||||
}
|
||||
ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain;
|
||||
function chainDiagnosticMessages(details, message) {
|
||||
var text = getLocaleSpecificMessage(message);
|
||||
if (arguments.length > 2) {
|
||||
@ -3046,6 +3057,7 @@ var ts;
|
||||
Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" },
|
||||
Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" },
|
||||
Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" },
|
||||
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" },
|
||||
};
|
||||
})(ts || (ts = {}));
|
||||
var ts;
|
||||
@ -21653,7 +21665,9 @@ var ts;
|
||||
else if (getObjectFlags(type) & 3 || type.flags & (16 | 16384)) {
|
||||
buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064, 0, nextFlags);
|
||||
}
|
||||
else if (!(flags & 512) && ((getObjectFlags(type) & 16 && !type.target) || type.flags & 196608) && type.aliasSymbol &&
|
||||
else if (!(flags & 512) &&
|
||||
(getObjectFlags(type) & 16 && !type.target || type.flags & 196608) &&
|
||||
type.aliasSymbol &&
|
||||
isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064, false).accessibility === 0) {
|
||||
var typeArguments = type.aliasTypeArguments;
|
||||
writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags);
|
||||
@ -21762,7 +21776,7 @@ var ts;
|
||||
}
|
||||
else if (ts.contains(symbolStack, symbol)) {
|
||||
var typeAlias = getTypeAliasForTypeLiteral(type);
|
||||
if (typeAlias) {
|
||||
if (typeAlias && !type.target) {
|
||||
buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793064, 0, flags);
|
||||
}
|
||||
else {
|
||||
@ -49531,10 +49545,20 @@ var ts;
|
||||
if (emitFileName) {
|
||||
var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName);
|
||||
if (filesByName.contains(emitFilePath)) {
|
||||
createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file);
|
||||
if (options.noEmitOverwritenFiles && !options.out && !options.outDir && !options.outFile) {
|
||||
blockEmittingOfFile(emitFileName);
|
||||
}
|
||||
else {
|
||||
var chain_1;
|
||||
if (!options.configFilePath) {
|
||||
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);
|
||||
}
|
||||
chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName);
|
||||
blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain_1));
|
||||
}
|
||||
}
|
||||
if (emitFilesSeen.contains(emitFilePath)) {
|
||||
createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files);
|
||||
blockEmittingOfFile(emitFileName, ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName));
|
||||
}
|
||||
else {
|
||||
emitFilesSeen.set(emitFilePath, true);
|
||||
@ -49542,9 +49566,11 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
function createEmitBlockingDiagnostics(emitFileName, message) {
|
||||
function blockEmittingOfFile(emitFileName, diag) {
|
||||
hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true);
|
||||
programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName));
|
||||
if (diag) {
|
||||
programDiagnostics.add(diag);
|
||||
}
|
||||
}
|
||||
}
|
||||
ts.createProgram = createProgram;
|
||||
@ -62510,6 +62536,9 @@ var ts;
|
||||
else if (hasExplicitListOfFiles) {
|
||||
this.compilerOptions.allowNonTsExtensions = true;
|
||||
}
|
||||
if (this.projectKind === ProjectKind.Inferred) {
|
||||
this.compilerOptions.noEmitOverwritenFiles = true;
|
||||
}
|
||||
if (languageServiceEnabled) {
|
||||
this.enableLanguageService();
|
||||
}
|
||||
|
||||
@ -2148,6 +2148,17 @@ var ts;
|
||||
};
|
||||
}
|
||||
ts.createCompilerDiagnostic = createCompilerDiagnostic;
|
||||
function createCompilerDiagnosticFromMessageChain(chain) {
|
||||
return {
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
code: chain.code,
|
||||
category: chain.category,
|
||||
messageText: chain.next ? chain : chain.messageText
|
||||
};
|
||||
}
|
||||
ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain;
|
||||
function chainDiagnosticMessages(details, message) {
|
||||
var text = getLocaleSpecificMessage(message);
|
||||
if (arguments.length > 2) {
|
||||
@ -4411,6 +4422,7 @@ var ts;
|
||||
Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" },
|
||||
Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" },
|
||||
Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" },
|
||||
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" },
|
||||
};
|
||||
})(ts || (ts = {}));
|
||||
/// <reference path="core.ts"/>
|
||||
@ -24845,14 +24857,31 @@ var ts;
|
||||
// The specified symbol flags need to be reinterpreted as type flags
|
||||
buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, nextFlags);
|
||||
}
|
||||
else if (!(flags & 512 /* InTypeAlias */) && ((getObjectFlags(type) & 16 /* Anonymous */ && !type.target) || type.flags & 196608 /* UnionOrIntersection */) && type.aliasSymbol &&
|
||||
else if (!(flags & 512 /* InTypeAlias */) &&
|
||||
(getObjectFlags(type) & 16 /* Anonymous */ && !type.target || type.flags & 196608 /* UnionOrIntersection */) &&
|
||||
type.aliasSymbol &&
|
||||
isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === 0 /* Accessible */) {
|
||||
// We emit inferred type as type-alias at the current localtion if all the following is true
|
||||
// the input type is has alias symbol that is accessible
|
||||
// the input type is a union, intersection or anonymous type that is fully instantiated (if not we want to keep dive into)
|
||||
// e.g.: export type Bar<X, Y> = () => [X, Y];
|
||||
// export type Foo<Y> = Bar<any, Y>;
|
||||
// export const y = (x: Foo<string>) => 1 // we want to emit as ...x: () => [any, string])
|
||||
// We emit inferred type as type-alias if type is not in type-alias declaration, existed accessible alias-symbol, type is anonymous or union or intersection.
|
||||
// However, if the type is an anonymous type with type arguments, we need to perform additional check.
|
||||
// 1) No type arguments, just emit type-alias as is
|
||||
// 2) Existed type arguments, check if the type arguments full fill all type parameters of the alias-symbol by
|
||||
// checking whether the target's aliasTypeArguments has the same size as type's aliasTypeArguments:
|
||||
// i.e
|
||||
// type Foo<T> = {
|
||||
// foo<U>(): Foo<U>
|
||||
// };
|
||||
// function foo() {
|
||||
// return {} as Foo<number>;
|
||||
// }
|
||||
// Should be emitted as
|
||||
// declare type Foo<T> = {
|
||||
// foo<U>(): Foo<U>;
|
||||
// };
|
||||
// declare function foo(): Foo<number>;
|
||||
// Otherwise type-alias is point to another generic type-alias then don't write it using alias symbol
|
||||
// export type Bar<X, Y> = () => [X, Y];
|
||||
// export type Foo<Y> = Bar<any, Y>;
|
||||
// export const y = (x: Foo<string>) => 1 // this should be emit as "export declare const y: (x: () => [any, string]) => number;"
|
||||
var typeArguments = type.aliasTypeArguments;
|
||||
writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags);
|
||||
}
|
||||
@ -24971,7 +25000,9 @@ var ts;
|
||||
else if (ts.contains(symbolStack, symbol)) {
|
||||
// If type is an anonymous type literal in a type alias declaration, use type alias name
|
||||
var typeAlias = getTypeAliasForTypeLiteral(type);
|
||||
if (typeAlias) {
|
||||
// We only want to use type-alias here if the typeAlias is not a generic one. (i.e it doesn't have a target type)
|
||||
// If it is a generic type-alias just write out "any"
|
||||
if (typeAlias && !type.target) {
|
||||
// The specified symbol flags need to be reinterpreted as type flags
|
||||
buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, flags);
|
||||
}
|
||||
@ -60182,12 +60213,23 @@ var ts;
|
||||
var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName);
|
||||
// Report error if the output overwrites input file
|
||||
if (filesByName.contains(emitFilePath)) {
|
||||
createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file);
|
||||
if (options.noEmitOverwritenFiles && !options.out && !options.outDir && !options.outFile) {
|
||||
blockEmittingOfFile(emitFileName);
|
||||
}
|
||||
else {
|
||||
var chain_1;
|
||||
if (!options.configFilePath) {
|
||||
// The program is from either an inferred project or an external project
|
||||
chain_1 = ts.chainDiagnosticMessages(/*details*/ 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);
|
||||
}
|
||||
chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName);
|
||||
blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain_1));
|
||||
}
|
||||
}
|
||||
// Report error if multiple files write into same file
|
||||
if (emitFilesSeen.contains(emitFilePath)) {
|
||||
// Already seen the same emit file - report error
|
||||
createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files);
|
||||
blockEmittingOfFile(emitFileName, ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName));
|
||||
}
|
||||
else {
|
||||
emitFilesSeen.set(emitFilePath, true);
|
||||
@ -60195,9 +60237,11 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
function createEmitBlockingDiagnostics(emitFileName, message) {
|
||||
function blockEmittingOfFile(emitFileName, diag) {
|
||||
hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true);
|
||||
programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName));
|
||||
if (diag) {
|
||||
programDiagnostics.add(diag);
|
||||
}
|
||||
}
|
||||
}
|
||||
ts.createProgram = createProgram;
|
||||
|
||||
@ -2148,6 +2148,17 @@ var ts;
|
||||
};
|
||||
}
|
||||
ts.createCompilerDiagnostic = createCompilerDiagnostic;
|
||||
function createCompilerDiagnosticFromMessageChain(chain) {
|
||||
return {
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
code: chain.code,
|
||||
category: chain.category,
|
||||
messageText: chain.next ? chain : chain.messageText
|
||||
};
|
||||
}
|
||||
ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain;
|
||||
function chainDiagnosticMessages(details, message) {
|
||||
var text = getLocaleSpecificMessage(message);
|
||||
if (arguments.length > 2) {
|
||||
@ -4411,6 +4422,7 @@ var ts;
|
||||
Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" },
|
||||
Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" },
|
||||
Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" },
|
||||
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" },
|
||||
};
|
||||
})(ts || (ts = {}));
|
||||
/// <reference path="core.ts"/>
|
||||
@ -24845,14 +24857,31 @@ var ts;
|
||||
// The specified symbol flags need to be reinterpreted as type flags
|
||||
buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, nextFlags);
|
||||
}
|
||||
else if (!(flags & 512 /* InTypeAlias */) && ((getObjectFlags(type) & 16 /* Anonymous */ && !type.target) || type.flags & 196608 /* UnionOrIntersection */) && type.aliasSymbol &&
|
||||
else if (!(flags & 512 /* InTypeAlias */) &&
|
||||
(getObjectFlags(type) & 16 /* Anonymous */ && !type.target || type.flags & 196608 /* UnionOrIntersection */) &&
|
||||
type.aliasSymbol &&
|
||||
isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, 793064 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === 0 /* Accessible */) {
|
||||
// We emit inferred type as type-alias at the current localtion if all the following is true
|
||||
// the input type is has alias symbol that is accessible
|
||||
// the input type is a union, intersection or anonymous type that is fully instantiated (if not we want to keep dive into)
|
||||
// e.g.: export type Bar<X, Y> = () => [X, Y];
|
||||
// export type Foo<Y> = Bar<any, Y>;
|
||||
// export const y = (x: Foo<string>) => 1 // we want to emit as ...x: () => [any, string])
|
||||
// We emit inferred type as type-alias if type is not in type-alias declaration, existed accessible alias-symbol, type is anonymous or union or intersection.
|
||||
// However, if the type is an anonymous type with type arguments, we need to perform additional check.
|
||||
// 1) No type arguments, just emit type-alias as is
|
||||
// 2) Existed type arguments, check if the type arguments full fill all type parameters of the alias-symbol by
|
||||
// checking whether the target's aliasTypeArguments has the same size as type's aliasTypeArguments:
|
||||
// i.e
|
||||
// type Foo<T> = {
|
||||
// foo<U>(): Foo<U>
|
||||
// };
|
||||
// function foo() {
|
||||
// return {} as Foo<number>;
|
||||
// }
|
||||
// Should be emitted as
|
||||
// declare type Foo<T> = {
|
||||
// foo<U>(): Foo<U>;
|
||||
// };
|
||||
// declare function foo(): Foo<number>;
|
||||
// Otherwise type-alias is point to another generic type-alias then don't write it using alias symbol
|
||||
// export type Bar<X, Y> = () => [X, Y];
|
||||
// export type Foo<Y> = Bar<any, Y>;
|
||||
// export const y = (x: Foo<string>) => 1 // this should be emit as "export declare const y: (x: () => [any, string]) => number;"
|
||||
var typeArguments = type.aliasTypeArguments;
|
||||
writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags);
|
||||
}
|
||||
@ -24971,7 +25000,9 @@ var ts;
|
||||
else if (ts.contains(symbolStack, symbol)) {
|
||||
// If type is an anonymous type literal in a type alias declaration, use type alias name
|
||||
var typeAlias = getTypeAliasForTypeLiteral(type);
|
||||
if (typeAlias) {
|
||||
// We only want to use type-alias here if the typeAlias is not a generic one. (i.e it doesn't have a target type)
|
||||
// If it is a generic type-alias just write out "any"
|
||||
if (typeAlias && !type.target) {
|
||||
// The specified symbol flags need to be reinterpreted as type flags
|
||||
buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, flags);
|
||||
}
|
||||
@ -60182,12 +60213,23 @@ var ts;
|
||||
var emitFilePath = ts.toPath(emitFileName, currentDirectory, getCanonicalFileName);
|
||||
// Report error if the output overwrites input file
|
||||
if (filesByName.contains(emitFilePath)) {
|
||||
createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file);
|
||||
if (options.noEmitOverwritenFiles && !options.out && !options.outDir && !options.outFile) {
|
||||
blockEmittingOfFile(emitFileName);
|
||||
}
|
||||
else {
|
||||
var chain_1;
|
||||
if (!options.configFilePath) {
|
||||
// The program is from either an inferred project or an external project
|
||||
chain_1 = ts.chainDiagnosticMessages(/*details*/ 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);
|
||||
}
|
||||
chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName);
|
||||
blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain_1));
|
||||
}
|
||||
}
|
||||
// Report error if multiple files write into same file
|
||||
if (emitFilesSeen.contains(emitFilePath)) {
|
||||
// Already seen the same emit file - report error
|
||||
createEmitBlockingDiagnostics(emitFileName, ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files);
|
||||
blockEmittingOfFile(emitFileName, ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName));
|
||||
}
|
||||
else {
|
||||
emitFilesSeen.set(emitFilePath, true);
|
||||
@ -60195,9 +60237,11 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
function createEmitBlockingDiagnostics(emitFileName, message) {
|
||||
function blockEmittingOfFile(emitFileName, diag) {
|
||||
hasEmitBlockingDiagnostics.set(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName), true);
|
||||
programDiagnostics.add(ts.createCompilerDiagnostic(message, emitFileName));
|
||||
if (diag) {
|
||||
programDiagnostics.add(diag);
|
||||
}
|
||||
}
|
||||
}
|
||||
ts.createProgram = createProgram;
|
||||
|
||||
@ -971,6 +971,17 @@ var ts;
|
||||
};
|
||||
}
|
||||
ts.createCompilerDiagnostic = createCompilerDiagnostic;
|
||||
function createCompilerDiagnosticFromMessageChain(chain) {
|
||||
return {
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
code: chain.code,
|
||||
category: chain.category,
|
||||
messageText: chain.next ? chain : chain.messageText
|
||||
};
|
||||
}
|
||||
ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain;
|
||||
function chainDiagnosticMessages(details, message) {
|
||||
var text = getLocaleSpecificMessage(message);
|
||||
if (arguments.length > 2) {
|
||||
@ -3046,6 +3057,7 @@ var ts;
|
||||
Implement_interface_on_reference: { code: 90005, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_reference_90005", message: "Implement interface on reference" },
|
||||
Implement_interface_on_class: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_on_class_90006", message: "Implement interface on class" },
|
||||
Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" },
|
||||
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" },
|
||||
};
|
||||
})(ts || (ts = {}));
|
||||
var ts;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user