Merge branch 'master' into vfs

This commit is contained in:
Ron Buckton
2017-12-19 16:31:59 -08:00
35 changed files with 361 additions and 147 deletions
+27 -6
View File
@@ -186,7 +186,11 @@ namespace ts {
},
isValidPropertyAccess: (node, propertyName) => {
node = getParseTreeNode(node, isPropertyAccessOrQualifiedName);
return node ? isValidPropertyAccess(node, escapeLeadingUnderscores(propertyName)) : false;
return !!node && isValidPropertyAccess(node, escapeLeadingUnderscores(propertyName));
},
isValidPropertyAccessForCompletions: (node, type, property) => {
node = getParseTreeNode(node, isPropertyAccessExpression);
return !!node && isValidPropertyAccessForCompletions(node, type, property);
},
getSignatureFromDeclaration: declaration => {
declaration = getParseTreeNode(declaration, isFunctionLike);
@@ -4678,6 +4682,7 @@ namespace ts {
}
else if (isJSDocPropertyTag(declaration)
|| isPropertyAccessExpression(declaration)
|| isIdentifier(declaration)
|| isMethodDeclaration(declaration) && !isObjectLiteralMethod(declaration)) {
// TODO: Mimics old behavior from incorrect usage of getWidenedTypeForVariableLikeDeclaration, but seems incorrect
type = tryGetTypeFromEffectiveTypeNode(declaration) || anyType;
@@ -16042,13 +16047,24 @@ namespace ts {
}
function isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: __String): boolean {
const left = node.kind === SyntaxKind.PropertyAccessExpression
? (<PropertyAccessExpression>node).expression
: (<QualifiedName>node).left;
const left = node.kind === SyntaxKind.PropertyAccessExpression ? node.expression : node.left;
return isValidPropertyAccessWithType(node, left, propertyName, getWidenedType(checkExpression(left)));
}
function isValidPropertyAccessForCompletions(node: PropertyAccessExpression, type: Type, property: Symbol): boolean {
return isValidPropertyAccessWithType(node, node.expression, property.escapedName, type)
&& (!(property.flags & ts.SymbolFlags.Method) || isValidMethodAccess(property, type));
}
function isValidMethodAccess(method: Symbol, type: Type) {
const propType = getTypeOfFuncClassEnumModule(method);
const signatures = getSignaturesOfType(propType, SignatureKind.Call);
Debug.assert(signatures.length !== 0);
return signatures.some(sig => {
const thisType = getThisTypeOfSignature(sig);
return !thisType || isTypeAssignableTo(type, thisType);
});
}
function isValidPropertyAccessWithType(
node: PropertyAccessExpression | QualifiedName,
left: LeftHandSideExpression | QualifiedName,
@@ -22724,7 +22740,12 @@ namespace ts {
const t = getTypeFromTypeNode(typeRefNode);
if (t !== unknownType) {
if (isValidBaseType(t)) {
checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, Diagnostics.Class_0_incorrectly_implements_interface_1);
checkTypeAssignableTo(typeWithThis,
getTypeWithThisArgument(t, type.thisType),
node.name || node,
t.symbol.flags & SymbolFlags.Class ?
Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
Diagnostics.Class_0_incorrectly_implements_interface_1);
}
else {
error(typeRefNode, Diagnostics.A_class_may_only_implement_another_class_or_interface);
+4
View File
@@ -2276,6 +2276,10 @@
"category": "Error",
"code": 2719
},
"Class '{0}' incorrectly implements class '{1}'. Did you mean to extend '{1}' and inherit its members as a subclass?": {
"category": "Error",
"code": 2720
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
+27 -15
View File
@@ -241,22 +241,28 @@ namespace ts {
return errorMessage;
}
const redForegroundEscapeSequence = "\u001b[91m";
const yellowForegroundEscapeSequence = "\u001b[93m";
const blueForegroundEscapeSequence = "\u001b[93m";
/** @internal */
export enum ForegroundColorEscapeSequences {
Grey = "\u001b[90m",
Red = "\u001b[91m",
Yellow = "\u001b[93m",
Blue = "\u001b[94m",
Cyan = "\u001b[96m"
}
const gutterStyleSequence = "\u001b[30;47m";
const gutterSeparator = " ";
const resetEscapeSequence = "\u001b[0m";
const ellipsis = "...";
function getCategoryFormat(category: DiagnosticCategory): string {
switch (category) {
case DiagnosticCategory.Warning: return yellowForegroundEscapeSequence;
case DiagnosticCategory.Error: return redForegroundEscapeSequence;
case DiagnosticCategory.Message: return blueForegroundEscapeSequence;
case DiagnosticCategory.Warning: return ForegroundColorEscapeSequences.Yellow;
case DiagnosticCategory.Error: return ForegroundColorEscapeSequences.Red;
case DiagnosticCategory.Message: return ForegroundColorEscapeSequences.Blue;
}
}
function formatAndReset(text: string, formatStyle: string) {
/** @internal */
export function formatColorAndReset(text: string, formatStyle: string) {
return formatStyle + text + resetEscapeSequence;
}
@@ -289,7 +295,7 @@ namespace ts {
// If the error spans over 5 lines, we'll only show the first 2 and last 2 lines,
// so we'll skip ahead to the second-to-last line.
if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) {
context += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine();
context += formatColorAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine();
i = lastLine - 1;
}
@@ -300,12 +306,12 @@ namespace ts {
lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces
// Output the gutter and the actual contents of the line.
context += formatAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator;
context += formatColorAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator;
context += lineContent + host.getNewLine();
// Output the gutter and the error span for the line using tildes.
context += formatAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator;
context += redForegroundEscapeSequence;
context += formatColorAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator;
context += ForegroundColorEscapeSequences.Red;
if (i === firstLine) {
// If we're on the last line, then limit it to the last character of the last line.
// Otherwise, we'll just squiggle the rest of the line, giving 'slice' no end position.
@@ -324,13 +330,19 @@ namespace ts {
context += resetEscapeSequence;
}
output += host.getNewLine();
output += `${ relativeFileName }(${ firstLine + 1 },${ firstLineChar + 1 }): `;
output += formatColorAndReset(relativeFileName, ForegroundColorEscapeSequences.Cyan);
output += "(";
output += formatColorAndReset(`${ firstLine + 1 }`, ForegroundColorEscapeSequences.Yellow);
output += ",";
output += formatColorAndReset(`${ firstLineChar + 1 }`, ForegroundColorEscapeSequences.Yellow);
output += "): ";
}
const categoryColor = getCategoryFormat(diagnostic.category);
const category = DiagnosticCategory[diagnostic.category].toLowerCase();
output += `${ formatAndReset(category, categoryColor) } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) }`;
output += formatColorAndReset(category, categoryColor);
output += formatColorAndReset(` TS${ diagnostic.code }: `, ForegroundColorEscapeSequences.Grey);
output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine());
if (diagnostic.file) {
output += host.getNewLine();
@@ -339,7 +351,7 @@ namespace ts {
output += host.getNewLine();
}
return output;
return output + host.getNewLine();
}
export function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string {
+2
View File
@@ -2785,6 +2785,8 @@ namespace ts {
getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): string | number | undefined;
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
/** Exclude accesses to private properties or methods with a `this` parameter that `type` doesn't satisfy. */
/* @internal */ isValidPropertyAccessForCompletions(node: PropertyAccessExpression, type: Type, property: Symbol): boolean;
/** Follow all aliases to get the original symbol. */
getAliasedSymbol(symbol: Symbol): Symbol;
/** Follow a *single* alias to get the immediately aliased symbol. */
+10 -1
View File
@@ -48,6 +48,15 @@ namespace ts {
};
}
/** @internal */
export function createWatchDiagnosticReporterWithColor(system = sys): DiagnosticReporter {
return diagnostic => {
let output = `[${ formatColorAndReset(new Date().toLocaleTimeString(), ForegroundColorEscapeSequences.Grey) }] `;
output += `${flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)}${system.newLine + system.newLine + system.newLine}`;
system.write(output);
};
}
export function reportDiagnostics(diagnostics: Diagnostic[], reportDiagnostic: DiagnosticReporter): void {
for (const diagnostic of diagnostics) {
reportDiagnostic(diagnostic);
@@ -131,7 +140,7 @@ namespace ts {
reportWatchDiagnostic?: DiagnosticReporter
): WatchingSystemHost {
reportDiagnostic = reportDiagnostic || createDiagnosticReporter(system, pretty ? reportDiagnosticWithColorAndContext : reportDiagnosticSimply);
reportWatchDiagnostic = reportWatchDiagnostic || createWatchDiagnosticReporter(system);
reportWatchDiagnostic = reportWatchDiagnostic || pretty ? createWatchDiagnosticReporterWithColor(system) : createWatchDiagnosticReporter(system);
parseConfigFile = parseConfigFile || ts.parseConfigFile;
return {
system,
@@ -154,7 +154,7 @@
<Str Cat="Text">
<Val><![CDATA[A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[方法重载中的计算属性名称必须引用类型为文本类型或 "unique symbol" 类型的表达式。]]></Val>
<Val><![CDATA[方法重载中的计算属性名称必须引用文本类型或 "unique symbol" 类型的表达式。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -1384,7 +1384,7 @@
<Str Cat="Text">
<Val><![CDATA[Annotate with type from JSDoc]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[使用 JSDoc 中的类型批注]]></Val>
<Val><![CDATA[通过 JSDoc 类型批注]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -3247,7 +3247,7 @@
<Str Cat="Text">
<Val><![CDATA[Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[運算式解析成編譯器用來擷取 'new.target' 中繼屬性參考的變數宣告 '_newTarget'。]]></Val>
<Val><![CDATA[運算式解析成變數宣告 '_newTarget',而供編譯器用來擷取 'new.target' 中繼屬性參考。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -6646,7 +6646,7 @@
<Str Cat="Text">
<Val><![CDATA[Stylize errors and messages using color and context (experimental).]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[使用色彩及內容設計錯誤與訊息的風格 (實驗)。]]></Val>
<Val><![CDATA[使用色彩及內容設計錯誤與訊息的風格 (實驗)。]]></Val>
</Tgt>
<Prev Cat="Text">
<Val><![CDATA[Stylize errors and messages using color and context. (experimental)]]></Val>
@@ -2191,7 +2191,7 @@
<Str Cat="Text">
<Val><![CDATA[Computed values are not permitted in an enum with string valued members.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Berechnete Werte sind in einer Aufzählung mit Membern mit Zeichenfolgenwerten nicht zulässig.]]></Val>
<Val><![CDATA[Berechnete Werte sind in einer Enumeration mit Membern mit Zeichenfolgenwerten nicht zulässig.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -436,7 +436,7 @@
<Str Cat="Text">
<Val><![CDATA[A mixin class must have a constructor with a single rest parameter of type 'any[]5D;'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Una clase mixin debe tener un constructor con un parámetro de REST sencillo del tipo "any[]5D;".]]></Val>
<Val><![CDATA[Una clase mixin debe tener un constructor con un solo parámetro rest de tipo "any[]5D;"]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -523,7 +523,7 @@
<Str Cat="Text">
<Val><![CDATA[A path in an 'extends' option must be relative or rooted, but '{0}' is not.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Una ruta de acceso en una opción "extiende" debe ser relativa o raíz, pero no '{0}'.]]></Val>
<Val><![CDATA[Una ruta de acceso en una opción "extiende" debe ser relativa o raíz, pero no "{0}".]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -1420,7 +1420,7 @@
<Str Cat="Text">
<Val><![CDATA[Argument for '{0}' option must be: {1}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[El argumento para la opción '{0}' debe ser: {1}.]]></Val>
<Val><![CDATA[El argumento para la opción "{0}" debe ser {1}.]]></Val>
</Tgt>
<Prev Cat="Text">
<Val><![CDATA[Argument for '{0}' option must be: {1}]]></Val>
@@ -1432,7 +1432,7 @@
<Str Cat="Text">
<Val><![CDATA[Argument of type '{0}' is not assignable to parameter of type '{1}'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[No se puede asignar un argumento de tipo '{0}' al parámetro de tipo '{1}'.]]></Val>
<Val><![CDATA[No se puede asignar un argumento de tipo "{0}" al parámetro de tipo "{1}".]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -3465,15 +3465,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0_5011" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[File specification cannot contain multiple recursive directory wildcards ('**'): '{0}'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[La especificación de archivo no puede contener varios comodines de directorio recursivo ('**'): '{0}'.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[File specification cannot end in a recursive directory wildcard ('**'): '{0}'.]]></Val>
@@ -1060,7 +1060,7 @@
<Str Cat="Text">
<Val><![CDATA[An arithmetic operand must be of type 'any', 'number' or an enum type.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Un operando aritmetico deve essere di tipo 'any', 'number' o un tipo di enum.]]></Val>
<Val><![CDATA[Un operando aritmetico deve essere di tipo 'any', 'number' o un tipo di enumerazione.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -1105,7 +1105,7 @@
<Str Cat="Text">
<Val><![CDATA[An enum member cannot have a numeric name.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Il nome di un membro enum non può essere numerico.]]></Val>
<Val><![CDATA[Il nome di un membro di enumerazione non può essere numerico.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -1978,7 +1978,7 @@
<Str Cat="Text">
<Val><![CDATA[Change 'extends' to 'implements']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Cambia 'extends' in 'implements']]></Val>
<Val><![CDATA[Cambiare 'extends' in 'implements']]></Val>
</Tgt>
<Prev Cat="Text">
<Val><![CDATA[Change 'extends' to 'implements'.]]></Val>
@@ -2158,7 +2158,7 @@
<Str Cat="Text">
<Val><![CDATA[Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Compila il progetto di cui è stato specificato il percorso del file di configurazione o di una cartella contenente un file 'tsconfig.json'.]]></Val>
<Val><![CDATA[Compila il progetto in base al percorso del file di configurazione o della cartella contenente un file 'tsconfig.json'.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -2581,7 +2581,7 @@
<Str Cat="Text">
<Val><![CDATA[Do not erase const enum declarations in generated code.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Non cancella le dichiarazioni enum const nel codice generato.]]></Val>
<Val><![CDATA[Non cancella le dichiarazioni di enumerazione const nel codice generato.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -2827,7 +2827,7 @@
<Str Cat="Text">
<Val><![CDATA[Emit a single file with source maps instead of having a separate file.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Crea un unico file con i mapping d origine invece di file separati.]]></Val>
<Val><![CDATA[Crea un unico file con i mapping di origine invece di file separati.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -2854,7 +2854,7 @@
<Str Cat="Text">
<Val><![CDATA[Enable strict checking of function types.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Abilitare il controllo tassativo dei tipi funzione.]]></Val>
<Val><![CDATA[Abilita il controllo tassativo dei tipi funzione.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -2926,7 +2926,7 @@
<Str Cat="Text">
<Val><![CDATA[Enum declarations must all be const or non-const.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Le dichiarazioni enum devono essere tutte const o tutte non const.]]></Val>
<Val><![CDATA[Le dichiarazioni di enumerazione devono essere tutte const o tutte non const.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -2935,7 +2935,7 @@
<Str Cat="Text">
<Val><![CDATA[Enum member expected.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[È previsto il membro enum.]]></Val>
<Val><![CDATA[È previsto il membro di enumerazione.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -2944,7 +2944,7 @@
<Str Cat="Text">
<Val><![CDATA[Enum member must have initializer.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Il membro enum deve contenere l'inizializzatore.]]></Val>
<Val><![CDATA[Il membro di enumerazione deve contenere l'inizializzatore.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -3028,7 +3028,7 @@
<Str Cat="Text">
<Val><![CDATA[Expected {0} type arguments; provide these with an '@extends' tag.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Sono previsti argomento tipo {0}. Per specificarli, usare un tag '@extends'.]]></Val>
<Val><![CDATA[Sono previsti {0} argomenti tipo. Per specificarli, usare un tag '@extends'.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -3046,7 +3046,7 @@
<Str Cat="Text">
<Val><![CDATA[Expected at least {0} arguments, but got {1} or more.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Sono previsti almeno {0} argomenti, ma ne sono stati ottenuti più di {1}.]]></Val>
<Val><![CDATA[Sono previsti almeno {0} argomenti, ma ne sono stati ottenuti {1} o più.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -3763,7 +3763,7 @@
<Str Cat="Text">
<Val><![CDATA[Implement inherited abstract class]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Implementa la classe astratta ereditata]]></Val>
<Val><![CDATA[Implementare la classe astratta ereditata]]></Val>
</Tgt>
<Prev Cat="Text">
<Val><![CDATA[Implement inherited abstract class.]]></Val>
@@ -3886,7 +3886,7 @@
<Str Cat="Text">
<Val><![CDATA[In ambient enum declarations member initializer must be constant expression.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Nelle dichiarazioni enum dell'ambiente l'inizializzatore di membro deve essere un'espressione costante.]]></Val>
<Val><![CDATA[Nelle dichiarazioni di enumerazione dell'ambiente l'inizializzatore di membro deve essere un'espressione costante.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -3895,7 +3895,7 @@
<Str Cat="Text">
<Val><![CDATA[In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[In un'enumerazione con più dichiarazioni solo una di queste può omettere un inizializzatore per il primo elemento enum.]]></Val>
<Val><![CDATA[In un'enumerazione con più dichiarazioni solo una di queste può omettere un inizializzatore per il primo elemento dell'enumerazione.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -3904,7 +3904,7 @@
<Str Cat="Text">
<Val><![CDATA[In 'const' enum declarations member initializer must be constant expression.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Nelle dichiarazioni enum 'const' l'inizializzatore di membro deve essere un'espressione costante.]]></Val>
<Val><![CDATA[Nelle dichiarazioni di enumerazione 'const' l'inizializzatore di membro deve essere un'espressione costante.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -6289,7 +6289,7 @@
<Str Cat="Text">
<Val><![CDATA[Return type of public static getter '{0}' from exported class has or is using private name '{1}'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Il tipo restituito del getter di proprietà pubblico '{0}' della classe esportata contiene o usa il nome privato '{1}'.]]></Val>
<Val><![CDATA[Il tipo restituito del getter statico pubblico '{0}' della classe esportata contiene o usa il nome privato '{1}'.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -7141,7 +7141,7 @@
<Str Cat="Text">
<Val><![CDATA[The target of an object rest assignment must be a variable or a property access.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[La destinazione di un'assegnazione rimanente dell'oggetto deve essere una variabile o un accesso a proprietà.]]></Val>
<Val><![CDATA[La destinazione di un'assegnazione REST di oggetto deve essere una variabile o un accesso a proprietà.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8473,7 +8473,7 @@
<Str Cat="Text">
<Val><![CDATA['const' enum member initializer was evaluated to a non-finite value.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[L'inizializzatore di membro enum 'const' è stato valutato come valore non finito.]]></Val>
<Val><![CDATA[L'inizializzatore del membro di enumerazione 'const' è stato valutato come valore non finito.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8482,7 +8482,7 @@
<Str Cat="Text">
<Val><![CDATA['const' enum member initializer was evaluated to disallowed value 'NaN'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[L'inizializzatore di membro enum 'const' è stato valutato come valore non consentito 'NaN'.]]></Val>
<Val><![CDATA[L'inizializzatore del membro di enumerazione 'const' è stato valutato come valore non consentito 'NaN'.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -418,7 +418,7 @@
<Str Cat="Text">
<Val><![CDATA[A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[enum 宣言のメンバー初期化子は、他の enum で定義されたメンバーを含め、その後で宣言されたメンバーを参照できません。]]></Val>
<Val><![CDATA[列挙型宣言のメンバー初期化子は、他の列挙型で定義されたメンバーを含め、その後で宣言されたメンバーを参照できません。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -1105,7 +1105,7 @@
<Str Cat="Text">
<Val><![CDATA[An enum member cannot have a numeric name.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[列挙メンバーに数値名を含めることはできません。]]></Val>
<Val><![CDATA[列挙メンバーに数値名を含めることはできません。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -2185,7 +2185,7 @@
<Str Cat="Text">
<Val><![CDATA[Computed property names are not allowed in enums.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[計算されたプロパティ名は列挙では使用できません。]]></Val>
<Val><![CDATA[計算されたプロパティ名は列挙では使用できません。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -2194,7 +2194,7 @@
<Str Cat="Text">
<Val><![CDATA[Computed values are not permitted in an enum with string valued members.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[文字列値のメンバーを持つ列挙では、計算値は許可されません。]]></Val>
<Val><![CDATA[文字列値のメンバーを持つ列挙では、計算値は許可されません。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -2581,7 +2581,7 @@
<Str Cat="Text">
<Val><![CDATA[Do not erase const enum declarations in generated code.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[生成されたコード内で const enum 宣言を消去しないでください。]]></Val>
<Val><![CDATA[生成されたコード内で const 列挙型宣言を消去しないでください。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -2926,7 +2926,7 @@
<Str Cat="Text">
<Val><![CDATA[Enum declarations must all be const or non-const.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[enum 宣言は、すべてが定数、またはすべてが非定数でなければなりません。]]></Val>
<Val><![CDATA[列挙型宣言は、すべてが定数、またはすべてが非定数でなければなりません。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -2944,7 +2944,7 @@
<Str Cat="Text">
<Val><![CDATA[Enum member must have initializer.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[列挙メンバーには初期化子が必要です。]]></Val>
<Val><![CDATA[列挙メンバーには初期化子が必要です。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -3895,7 +3895,7 @@
<Str Cat="Text">
<Val><![CDATA[In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[複数の宣言がある列挙で、最初の列挙要素の初期化子を省略できる宣言は 1 つのみです。]]></Val>
<Val><![CDATA[複数の宣言がある列挙で、最初の列挙要素の初期化子を省略できる宣言は 1 つのみです。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -4927,7 +4927,7 @@
<Str Cat="Text">
<Val><![CDATA[Octal literals are not allowed in enums members initializer. Use the syntax '{0}'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[8 進数のリテラルは、列挙メンバーの初期化子では許可されていません。構文 '{0}' を使用してください。]]></Val>
<Val><![CDATA[8 進数のリテラルは、列挙メンバーの初期化子では許可されていません。構文 '{0}' を使用してください。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -5506,7 +5506,7 @@
<Str Cat="Text">
<Val><![CDATA[Property '{0}' does not exist on 'const' enum '{1}'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[プロパティ '{0}' が 'const' 列挙 '{1}' に存在しません。]]></Val>
<Val><![CDATA[プロパティ '{0}' が 'const' 列挙 '{1}' に存在しません。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8473,7 +8473,7 @@
<Str Cat="Text">
<Val><![CDATA['const' enum member initializer was evaluated to a non-finite value.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA['const' 列挙メンバーの初期化子が、無限値に評価されました。]]></Val>
<Val><![CDATA['const' 列挙メンバーの初期化子が、無限値に評価されました。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8482,7 +8482,7 @@
<Str Cat="Text">
<Val><![CDATA['const' enum member initializer was evaluated to disallowed value 'NaN'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA['const' 列挙メンバーの初期化子が、許可されない値 'NaN' に評価されました。]]></Val>
<Val><![CDATA['const' 列挙メンバーの初期化子が、許可されない値 'NaN' に評価されました。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -8509,7 +8509,7 @@
<Str Cat="Text">
<Val><![CDATA['enum declarations' can only be used in a .ts file.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA['enum 宣言' を使用できるのは .ts ファイル内のみです。]]></Val>
<Val><![CDATA['列挙型宣言' を使用できるのは .ts ファイル内のみです。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -1374,7 +1374,7 @@
<Str Cat="Text">
<Val><![CDATA[Annotate with type from JSDoc]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Dodaj adnotację przy użyciu typu z JSDoc]]></Val>
<Val><![CDATA[Dodaj adnotację z typem z danych JSDoc]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -1383,7 +1383,7 @@
<Str Cat="Text">
<Val><![CDATA[Annotate with types from JSDoc]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Dodaj adnotację przy użyciu typów z JSDoc]]></Val>
<Val><![CDATA[Dodaj adnotację z typami z danych JSDoc]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -276,7 +276,7 @@
<Str Cat="Text">
<Val><![CDATA[A decorator can only decorate a method implementation, not an overload.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Um decorador pode decoras somente uma implementação de método, não uma sobrecarga.]]></Val>
<Val><![CDATA[Um decorador pode decorar somente uma implementação de método, não uma sobrecarga.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -411,7 +411,7 @@
<Str Cat="Text">
<Val><![CDATA[A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[O inicializador de um membro em uma declaração enum não pode referenciar membros declarados depois dele, inclusive membros definidos em outros enums.]]></Val>
<Val><![CDATA[O inicializador de um membro em uma declaração de enumeração não pode referenciar membros declarados depois dele, inclusive membros definidos em outras enumerações.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -1050,7 +1050,7 @@
<Str Cat="Text">
<Val><![CDATA[An arithmetic operand must be of type 'any', 'number' or an enum type.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Um operando aritmético deve ser do tipo 'any', 'number' ou um tipo enum.]]></Val>
<Val><![CDATA[Um operando aritmético deve ser do tipo 'any', 'number' ou um tipo de enumeração.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -1095,7 +1095,7 @@
<Str Cat="Text">
<Val><![CDATA[An enum member cannot have a numeric name.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Um membro enum não pode ter um nome numérico.]]></Val>
<Val><![CDATA[Um membro de enumeração não pode ter um nome numérico.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -2184,7 +2184,7 @@
<Str Cat="Text">
<Val><![CDATA[Computed values are not permitted in an enum with string valued members.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Os valores computados não são permitidos em um enum com membros de valor de cadeia de caracteres.]]></Val>
<Val><![CDATA[Os valores computados não são permitidos em uma enumeração com membros de valor de cadeia de caracteres.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -2907,7 +2907,7 @@
<Str Cat="Text">
<Val><![CDATA[Enum '{0}' used before its declaration.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Enum '{0}' usada antes de sua declaração.]]></Val>
<Val><![CDATA[A enumeração '{0}' usada antes de sua declaração.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -2916,7 +2916,7 @@
<Str Cat="Text">
<Val><![CDATA[Enum declarations must all be const or non-const.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Declarações enum devem ser const ou não const.]]></Val>
<Val><![CDATA[Declarações de enumeração devem ser const ou não const.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -2925,7 +2925,7 @@
<Str Cat="Text">
<Val><![CDATA[Enum member expected.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Membro enum esperado.]]></Val>
<Val><![CDATA[Membro de enumeração esperado.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -2934,7 +2934,7 @@
<Str Cat="Text">
<Val><![CDATA[Enum member must have initializer.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[O membro enum deve ter um inicializador.]]></Val>
<Val><![CDATA[O membro de enumeração deve ter um inicializador.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -2943,7 +2943,7 @@
<Str Cat="Text">
<Val><![CDATA[Enum name cannot be '{0}'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[O nome de enum não pode ser '{0}'.]]></Val>
<Val><![CDATA[O nome de enumeração não pode ser '{0}'.]]></Val>
</Tgt>
<Prev Cat="Text">
<Val><![CDATA[Enum name cannot be '{0}']]></Val>
@@ -2955,7 +2955,7 @@
<Str Cat="Text">
<Val><![CDATA[Enum type '{0}' has members with initializers that are not literals.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[O tipo Enum '{0}' tem membros com inicializadores que não são literais.]]></Val>
<Val><![CDATA[O tipo de Enumeração '{0}' tem membros com inicializadores que não são literais.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -3876,7 +3876,7 @@
<Str Cat="Text">
<Val><![CDATA[In ambient enum declarations member initializer must be constant expression.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Em declarações enum de ambiente, o inicializador de membro deve ser uma expressão de constante.]]></Val>
<Val><![CDATA[Em declarações de enumeração de ambiente, o inicializador de membro deve ser uma expressão de constante.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -3885,7 +3885,7 @@
<Str Cat="Text">
<Val><![CDATA[In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Em um enum com várias declarações, somente uma declaração pode omitir um inicializador para o primeiro elemento enum.]]></Val>
<Val><![CDATA[Em uma enumeração com várias declarações, somente uma declaração pode omitir um inicializador para o primeiro elemento de enumeração.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -6936,7 +6936,7 @@
<Str Cat="Text">
<Val><![CDATA[The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[O lado esquerdo de uma operação aritmética deve ser do tipo 'any', 'number' ou enum.]]></Val>
<Val><![CDATA[O lado esquerdo de uma operação aritmética deve ser do tipo 'any', 'number' ou de enumeração.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -7074,7 +7074,7 @@
<Str Cat="Text">
<Val><![CDATA[The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[O lado direito de uma operação aritmética deve ser do tipo 'any', 'number' ou enum.]]></Val>
<Val><![CDATA[O lado direito de uma operação aritmética deve ser do tipo 'any', 'number' ou de enumeração.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -3036,7 +3036,7 @@
<Str Cat="Text">
<Val><![CDATA[Expected at least {0} arguments, but got {1}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Ожидалось аргументов не менее: {0}, получено: {1}.]]></Val>
<Val><![CDATA[Ожидалось аргументов не меньше: {0}, получено: {1}.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -3455,15 +3455,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0_5011" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[File specification cannot contain multiple recursive directory wildcards ('**'): '{0}'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Спецификация файла не может содержать несколько рекурсивных подстановочных знаков каталога ("**"): "{0}".]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[File specification cannot end in a recursive directory wildcard ('**'): '{0}'.]]></Val>
@@ -1,6 +1,7 @@
/* @internal */
namespace ts.codefix {
const errorCodes = [Diagnostics.Class_0_incorrectly_implements_interface_1.code];
const errorCodes = [Diagnostics.Class_0_incorrectly_implements_interface_1.code,
Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code];
const fixId = "fixClassIncorrectlyImplementsInterface"; // TODO: share a group with fixClassDoesntImplementInheritedAbstractMember?
registerCodeFix({
errorCodes,
+8 -7
View File
@@ -238,7 +238,7 @@ namespace ts.Completions {
function getStringLiteralCompletionEntries(sourceFile: SourceFile, position: number, typeChecker: TypeChecker, compilerOptions: CompilerOptions, host: LanguageServiceHost, log: Log): CompletionInfo | undefined {
const node = findPrecedingToken(position, sourceFile);
if (!node || node.kind !== SyntaxKind.StringLiteral) {
if (!node || (node.kind !== SyntaxKind.StringLiteral && node.kind !== SyntaxKind.NoSubstitutionTemplateLiteral)) {
return undefined;
}
@@ -303,7 +303,7 @@ namespace ts.Completions {
// Get completion for string literal from string literal type
// i.e. var x: "hi" | "hello" = "/*completion position*/"
return getStringLiteralCompletionEntriesFromType(typeChecker.getContextualType(<StringLiteral>node), typeChecker);
return getStringLiteralCompletionEntriesFromType(typeChecker.getContextualType(<LiteralExpression>node), typeChecker);
}
}
@@ -918,9 +918,8 @@ namespace ts.Completions {
symbols.push(...getPropertiesForCompletion(type, typeChecker, /*isForAccess*/ true));
}
else {
// Filter private properties
for (const symbol of type.getApparentProperties()) {
if (typeChecker.isValidPropertyAccess(<PropertyAccessExpression>(node.parent), symbol.name)) {
if (typeChecker.isValidPropertyAccessForCompletions(<PropertyAccessExpression>(node.parent), type, symbol)) {
symbols.push(symbol);
}
}
@@ -1761,7 +1760,10 @@ namespace ts.Completions {
return true;
}
return isDeclarationName(contextToken) && !isJsxAttribute(contextToken.parent);
return isDeclarationName(contextToken)
&& !isJsxAttribute(contextToken.parent)
// Don't block completions if we're in `class C /**/`, because we're *past* the end of the identifier and might want to complete `extends`.
&& !(isClassLike(contextToken.parent) && position > previousToken.end);
}
function isFunctionLikeButNotConstructor(kind: SyntaxKind) {
@@ -2119,8 +2121,7 @@ namespace ts.Completions {
/**
* Gets all properties on a type, but if that type is a union of several types,
* tries to only include those types which declare properties, not methods.
* This ensures that we don't try providing completions for all the methods on e.g. Array.
* excludes array-like types or callable/constructable types.
*/
function getPropertiesForCompletion(type: Type, checker: TypeChecker, isForAccess: boolean): Symbol[] {
if (!(type.flags & TypeFlags.Union)) {
@@ -1,4 +1,4 @@
tests/cases/compiler/classImplementsClass2.ts(2,7): error TS2420: Class 'C' incorrectly implements interface 'A'.
tests/cases/compiler/classImplementsClass2.ts(2,7): error TS2720: Class 'C' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass?
Property 'foo' is missing in type 'C'.
tests/cases/compiler/classImplementsClass2.ts(13,1): error TS2322: Type 'C' is not assignable to type 'C2'.
Property 'foo' is missing in type 'C'.
@@ -8,8 +8,8 @@ tests/cases/compiler/classImplementsClass2.ts(13,1): error TS2322: Type 'C' is n
class A { foo(): number { return 1; } }
class C implements A {} // error
~
!!! error TS2420: Class 'C' incorrectly implements interface 'A'.
!!! error TS2420: Property 'foo' is missing in type 'C'.
!!! error TS2720: Class 'C' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass?
!!! error TS2720: Property 'foo' is missing in type 'C'.
class C2 extends A {
foo() {
@@ -1,4 +1,4 @@
tests/cases/compiler/classImplementsClass4.ts(5,7): error TS2420: Class 'C' incorrectly implements interface 'A'.
tests/cases/compiler/classImplementsClass4.ts(5,7): error TS2720: Class 'C' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass?
Property 'x' is missing in type 'C'.
tests/cases/compiler/classImplementsClass4.ts(16,1): error TS2322: Type 'C' is not assignable to type 'C2'.
Property 'x' is missing in type 'C'.
@@ -11,8 +11,8 @@ tests/cases/compiler/classImplementsClass4.ts(16,1): error TS2322: Type 'C' is n
}
class C implements A {
~
!!! error TS2420: Class 'C' incorrectly implements interface 'A'.
!!! error TS2420: Property 'x' is missing in type 'C'.
!!! error TS2720: Class 'C' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass?
!!! error TS2720: Property 'x' is missing in type 'C'.
foo() {
return 1;
}
@@ -1,4 +1,4 @@
tests/cases/compiler/classImplementsClass5.ts(5,7): error TS2420: Class 'C' incorrectly implements interface 'A'.
tests/cases/compiler/classImplementsClass5.ts(5,7): error TS2720: Class 'C' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass?
Types have separate declarations of a private property 'x'.
tests/cases/compiler/classImplementsClass5.ts(16,1): error TS2322: Type 'C2' is not assignable to type 'C'.
Types have separate declarations of a private property 'x'.
@@ -13,8 +13,8 @@ tests/cases/compiler/classImplementsClass5.ts(17,1): error TS2322: Type 'C' is n
}
class C implements A {
~
!!! error TS2420: Class 'C' incorrectly implements interface 'A'.
!!! error TS2420: Types have separate declarations of a private property 'x'.
!!! error TS2720: Class 'C' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass?
!!! error TS2720: Types have separate declarations of a private property 'x'.
private x = 1;
foo() {
return 1;
@@ -0,0 +1,14 @@
tests/cases/compiler/classImplementsClass7.ts(5,7): error TS2720: Class 'B' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass?
Property 'x' is missing in type 'B'.
==== tests/cases/compiler/classImplementsClass7.ts (1 errors) ====
class A {
private x: number;
}
class B implements A {}
~
!!! error TS2720: Class 'B' incorrectly implements class 'A'. Did you mean to extend 'A' and inherit its members as a subclass?
!!! error TS2720: Property 'x' is missing in type 'B'.
@@ -0,0 +1,19 @@
//// [classImplementsClass7.ts]
class A {
private x: number;
}
class B implements A {}
//// [classImplementsClass7.js]
var A = /** @class */ (function () {
function A() {
}
return A;
}());
var B = /** @class */ (function () {
function B() {
}
return B;
}());
@@ -0,0 +1,12 @@
=== tests/cases/compiler/classImplementsClass7.ts ===
class A {
>A : Symbol(A, Decl(classImplementsClass7.ts, 0, 0))
private x: number;
>x : Symbol(A.x, Decl(classImplementsClass7.ts, 0, 9))
}
class B implements A {}
>B : Symbol(B, Decl(classImplementsClass7.ts, 2, 1))
>A : Symbol(A, Decl(classImplementsClass7.ts, 0, 0))
@@ -0,0 +1,12 @@
=== tests/cases/compiler/classImplementsClass7.ts ===
class A {
>A : A
private x: number;
>x : number
}
class B implements A {}
>B : B
>A : A
@@ -1,8 +1,8 @@
tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts(9,7): error TS2420: Class 'C2' incorrectly implements interface 'C1'.
tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts(9,7): error TS2720: Class 'C2' incorrectly implements class 'C1'. Did you mean to extend 'C1' and inherit its members as a subclass?
Property 'x' is missing in type 'C2'.
tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts(12,7): error TS2420: Class 'C3' incorrectly implements interface 'C1'.
tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts(12,7): error TS2720: Class 'C3' incorrectly implements class 'C1'. Did you mean to extend 'C1' and inherit its members as a subclass?
Property 'y' is missing in type 'C3'.
tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts(16,7): error TS2420: Class 'C4' incorrectly implements interface 'C1'.
tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInterface.ts(16,7): error TS2720: Class 'C4' incorrectly implements class 'C1'. Did you mean to extend 'C1' and inherit its members as a subclass?
Property 'x' is missing in type 'C4'.
@@ -17,21 +17,21 @@ tests/cases/conformance/classes/classDeclarations/classImplementsMergedClassInte
class C2 implements C1 { // error -- missing x
~~
!!! error TS2420: Class 'C2' incorrectly implements interface 'C1'.
!!! error TS2420: Property 'x' is missing in type 'C2'.
!!! error TS2720: Class 'C2' incorrectly implements class 'C1'. Did you mean to extend 'C1' and inherit its members as a subclass?
!!! error TS2720: Property 'x' is missing in type 'C2'.
}
class C3 implements C1 { // error -- missing y
~~
!!! error TS2420: Class 'C3' incorrectly implements interface 'C1'.
!!! error TS2420: Property 'y' is missing in type 'C3'.
!!! error TS2720: Class 'C3' incorrectly implements class 'C1'. Did you mean to extend 'C1' and inherit its members as a subclass?
!!! error TS2720: Property 'y' is missing in type 'C3'.
x : number;
}
class C4 implements C1 { // error -- missing x
~~
!!! error TS2420: Class 'C4' incorrectly implements interface 'C1'.
!!! error TS2420: Property 'x' is missing in type 'C4'.
!!! error TS2720: Class 'C4' incorrectly implements class 'C1'. Did you mean to extend 'C1' and inherit its members as a subclass?
!!! error TS2720: Property 'x' is missing in type 'C4'.
y : number;
}
@@ -1,4 +1,4 @@
tests/cases/compiler/extendAndImplementTheSameBaseType2.ts(7,7): error TS2420: Class 'D' incorrectly implements interface 'C<number>'.
tests/cases/compiler/extendAndImplementTheSameBaseType2.ts(7,7): error TS2720: Class 'D' incorrectly implements class 'C<number>'. Did you mean to extend 'C<number>' and inherit its members as a subclass?
Types of property 'bar' are incompatible.
Type '() => string' is not assignable to type '() => number'.
Type 'string' is not assignable to type 'number'.
@@ -15,10 +15,10 @@ tests/cases/compiler/extendAndImplementTheSameBaseType2.ts(16,5): error TS2322:
}
class D extends C<string> implements C<number> {
~
!!! error TS2420: Class 'D' incorrectly implements interface 'C<number>'.
!!! error TS2420: Types of property 'bar' are incompatible.
!!! error TS2420: Type '() => string' is not assignable to type '() => number'.
!!! error TS2420: Type 'string' is not assignable to type 'number'.
!!! error TS2720: Class 'D' incorrectly implements class 'C<number>'. Did you mean to extend 'C<number>' and inherit its members as a subclass?
!!! error TS2720: Types of property 'bar' are incompatible.
!!! error TS2720: Type '() => string' is not assignable to type '() => number'.
!!! error TS2720: Type 'string' is not assignable to type 'number'.
baz() { }
}
@@ -1,10 +1,10 @@
tests/cases/compiler/genericSpecializations2.ts(7,7): error TS2420: Class 'IntFooBad' incorrectly implements interface 'IFoo<number>'.
tests/cases/compiler/genericSpecializations2.ts(7,7): error TS2720: Class 'IntFooBad' incorrectly implements class 'IFoo<number>'. Did you mean to extend 'IFoo<number>' and inherit its members as a subclass?
Types of property 'foo' are incompatible.
Type '<string>(x: string) => string' is not assignable to type '<T>(x: T) => T'.
Types of parameters 'x' and 'x' are incompatible.
Type 'T' is not assignable to type 'string'.
tests/cases/compiler/genericSpecializations2.ts(8,9): error TS2368: Type parameter name cannot be 'string'.
tests/cases/compiler/genericSpecializations2.ts(11,7): error TS2420: Class 'StringFoo2' incorrectly implements interface 'IFoo<string>'.
tests/cases/compiler/genericSpecializations2.ts(11,7): error TS2720: Class 'StringFoo2' incorrectly implements class 'IFoo<string>'. Did you mean to extend 'IFoo<string>' and inherit its members as a subclass?
Types of property 'foo' are incompatible.
Type '<string>(x: string) => string' is not assignable to type '<T>(x: T) => T'.
Types of parameters 'x' and 'x' are incompatible.
@@ -21,11 +21,11 @@ tests/cases/compiler/genericSpecializations2.ts(12,9): error TS2368: Type parame
class IntFooBad implements IFoo<number> {
~~~~~~~~~
!!! error TS2420: Class 'IntFooBad' incorrectly implements interface 'IFoo<number>'.
!!! error TS2420: Types of property 'foo' are incompatible.
!!! error TS2420: Type '<string>(x: string) => string' is not assignable to type '<T>(x: T) => T'.
!!! error TS2420: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2420: Type 'T' is not assignable to type 'string'.
!!! error TS2720: Class 'IntFooBad' incorrectly implements class 'IFoo<number>'. Did you mean to extend 'IFoo<number>' and inherit its members as a subclass?
!!! error TS2720: Types of property 'foo' are incompatible.
!!! error TS2720: Type '<string>(x: string) => string' is not assignable to type '<T>(x: T) => T'.
!!! error TS2720: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2720: Type 'T' is not assignable to type 'string'.
foo<string>(x: string): string { return null; }
~~~~~~
!!! error TS2368: Type parameter name cannot be 'string'.
@@ -33,11 +33,11 @@ tests/cases/compiler/genericSpecializations2.ts(12,9): error TS2368: Type parame
class StringFoo2 implements IFoo<string> {
~~~~~~~~~~
!!! error TS2420: Class 'StringFoo2' incorrectly implements interface 'IFoo<string>'.
!!! error TS2420: Types of property 'foo' are incompatible.
!!! error TS2420: Type '<string>(x: string) => string' is not assignable to type '<T>(x: T) => T'.
!!! error TS2420: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2420: Type 'T' is not assignable to type 'string'.
!!! error TS2720: Class 'StringFoo2' incorrectly implements class 'IFoo<string>'. Did you mean to extend 'IFoo<string>' and inherit its members as a subclass?
!!! error TS2720: Types of property 'foo' are incompatible.
!!! error TS2720: Type '<string>(x: string) => string' is not assignable to type '<T>(x: T) => T'.
!!! error TS2720: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2720: Type 'T' is not assignable to type 'string'.
foo<string>(x: string): string { return null; }
~~~~~~
!!! error TS2368: Type parameter name cannot be 'string'.
@@ -1,10 +1,10 @@
tests/cases/compiler/index.ts(2,1): error TS1005: '}' expected.
tests/cases/compiler/index.ts(2,1): error TS1005: '}' expected.
2
  
==== tests/cases/compiler/index.ts (1 errors) ====
if (true) {
@@ -0,0 +1,28 @@
=== tests/cases/conformance/salsa/index.js ===
Common.Item = class I {}
>Common : Symbol(Common, Decl(index.js, 0, 0), Decl(roots.js, 0, 3))
>I : Symbol(I, Decl(index.js, 0, 13))
Common.Object = class extends Common.Item {}
>Common : Symbol(Common, Decl(index.js, 0, 0), Decl(roots.js, 0, 3))
>Common.Item : Symbol(Common.Item, Decl(index.js, 0, 0))
>Common : Symbol(Common, Decl(index.js, 0, 0), Decl(roots.js, 0, 3))
>Item : Symbol(Common.Item, Decl(index.js, 0, 0))
Workspace.Object = class extends Common.Object {}
>Workspace : Symbol(Workspace, Decl(index.js, 1, 44), Decl(roots.js, 1, 3))
>Common.Object : Symbol(Common.Object, Decl(index.js, 0, 24))
>Common : Symbol(Common, Decl(index.js, 0, 0), Decl(roots.js, 0, 3))
>Object : Symbol(Common.Object, Decl(index.js, 0, 24))
/** @type {Workspace.Object} */
var am;
>am : Symbol(am, Decl(index.js, 6, 3))
=== tests/cases/conformance/salsa/roots.js ===
var Common = {};
>Common : Symbol(Common, Decl(index.js, 0, 0), Decl(roots.js, 0, 3))
var Workspace = {};
>Workspace : Symbol(Workspace, Decl(index.js, 1, 44), Decl(roots.js, 1, 3))
@@ -0,0 +1,42 @@
=== tests/cases/conformance/salsa/index.js ===
Common.Item = class I {}
>Common.Item = class I {} : typeof I
>Common.Item : any
>Common : any
>Item : any
>class I {} : typeof I
>I : typeof I
Common.Object = class extends Common.Item {}
>Common.Object = class extends Common.Item {} : typeof (Anonymous class)
>Common.Object : any
>Common : any
>Object : any
>class extends Common.Item {} : typeof (Anonymous class)
>Common.Item : any
>Common : any
>Item : any
Workspace.Object = class extends Common.Object {}
>Workspace.Object = class extends Common.Object {} : typeof (Anonymous class)
>Workspace.Object : any
>Workspace : any
>Object : any
>class extends Common.Object {} : typeof (Anonymous class)
>Common.Object : any
>Common : any
>Object : any
/** @type {Workspace.Object} */
var am;
>am : (Anonymous class)
=== tests/cases/conformance/salsa/roots.js ===
var Common = {};
>Common : any
>{} : { [x: string]: any; }
var Workspace = {};
>Workspace : any
>{} : { [x: string]: any; }
@@ -12,8 +12,8 @@ Standard output:
../../../../built/local/lib.dom.d.ts(9253,13): error TS2300: Duplicate identifier 'Request'.
../../../../built/local/lib.dom.d.ts(13511,11): error TS2300: Duplicate identifier 'Window'.
../../../../built/local/lib.dom.d.ts(13700,13): error TS2300: Duplicate identifier 'Window'.
../../../../built/local/lib.es5.d.ts(1322,11): error TS2300: Duplicate identifier 'ArrayLike'.
../../../../built/local/lib.es5.d.ts(1351,6): error TS2300: Duplicate identifier 'Record'.
../../../../built/local/lib.es5.d.ts(1321,11): error TS2300: Duplicate identifier 'ArrayLike'.
../../../../built/local/lib.es5.d.ts(1350,6): error TS2300: Duplicate identifier 'Record'.
node_modules/chrome-devtools-frontend/front_end/Runtime.js(43,8): error TS2339: Property '_importScriptPathPrefix' does not exist on type 'Window'.
node_modules/chrome-devtools-frontend/front_end/Runtime.js(95,28): error TS2339: Property 'response' does not exist on type 'EventTarget'.
node_modules/chrome-devtools-frontend/front_end/Runtime.js(147,37): error TS2339: Property '_importScriptPathPrefix' does not exist on type 'Window'.
@@ -0,0 +1,5 @@
class A {
private x: number;
}
class B implements A {}
@@ -0,0 +1,16 @@
// @noEmit: true
// @allowJs: true
// @checkJs: true
// @target: es3
// @filename: index.js
Common.Item = class I {}
Common.Object = class extends Common.Item {}
Workspace.Object = class extends Common.Object {}
/** @type {Workspace.Object} */
var am;
// @filename: roots.js
var Common = {};
var Workspace = {};
@@ -0,0 +1,8 @@
/// <reference path="fourslash.ts" />
////let count: 'one' | 'two';
////count = `/**/`
goTo.marker();
verify.completionListContains('one');
verify.completionListContains('two');
@@ -0,0 +1,11 @@
/// <reference path="fourslash.ts" />
////class C/*a*/ /*b*/ { }
// Tests that `isCompletionListBlocker` is true *at* the class name, but false *after* it.
goTo.marker("a");
verify.completionListIsEmpty();
goTo.marker("b");
verify.completionListContains("extends");
@@ -0,0 +1,15 @@
/// <reference path='fourslash.ts'/>
////class A<T> {
//// value: T; // Make the type parameter actually matter
//// ms(this: A<string>) {}
//// mo(this: A<{}>) {}
////}
////
////const s = new A<string>();
////const n = new A<number>();
////s./*s*/;
////n./*n*/;
verify.completionsAt("s", ["value", "ms", "mo"]);
verify.completionsAt("n", ["value", "mo"]);