Skip to content

Commit a29e8cf

Browse files
committed
Update LKG
1 parent 1120971 commit a29e8cf

12 files changed

+319
-37
lines changed

lib/lib.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ interface ObjectConstructor {
160160
* Creates an object that has the specified prototype or that has null prototype.
161161
* @param o Object to use as a prototype. May be null.
162162
*/
163-
create<T extends object>(o: T | null): T | object;
163+
create(o: object | null): any;
164164

165165
/**
166166
* Creates an object that has the specified prototype, and that optionally contains specified properties.

lib/lib.es5.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ interface ObjectConstructor {
160160
* Creates an object that has the specified prototype or that has null prototype.
161161
* @param o Object to use as a prototype. May be null.
162162
*/
163-
create<T extends object>(o: T | null): T | object;
163+
create(o: object | null): any;
164164

165165
/**
166166
* Creates an object that has the specified prototype, and that optionally contains specified properties.

lib/lib.es6.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ interface ObjectConstructor {
160160
* Creates an object that has the specified prototype or that has null prototype.
161161
* @param o Object to use as a prototype. May be null.
162162
*/
163-
create<T extends object>(o: T | null): T | object;
163+
create(o: object | null): any;
164164

165165
/**
166166
* Creates an object that has the specified prototype, and that optionally contains specified properties.

lib/tsc.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3347,7 +3347,9 @@ var ts;
33473347
Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." },
33483348
Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" },
33493349
Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" },
3350-
Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" },
3350+
Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}." },
3351+
Add_declaration_for_missing_property_0: { code: 90016, category: ts.DiagnosticCategory.Message, key: "Add_declaration_for_missing_property_0_90016", message: "Add declaration for missing property '{0}'." },
3352+
Add_index_signature_for_missing_property_0: { code: 90017, category: ts.DiagnosticCategory.Message, key: "Add_index_signature_for_missing_property_0_90017", message: "Add index signature for missing property '{0}'" },
33513353
Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." },
33523354
Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." },
33533355
};
@@ -20115,6 +20117,8 @@ var ts;
2011520117
getSignaturesOfType: getSignaturesOfType,
2011620118
getIndexTypeOfType: getIndexTypeOfType,
2011720119
getBaseTypes: getBaseTypes,
20120+
getBaseTypeOfLiteralType: getBaseTypeOfLiteralType,
20121+
getWidenedType: getWidenedType,
2011820122
getTypeFromTypeNode: getTypeFromTypeNode,
2011920123
getParameterType: getTypeAtPosition,
2012020124
getReturnTypeOfSignature: getReturnTypeOfSignature,

lib/tsserver.js

Lines changed: 73 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4308,7 +4308,9 @@ var ts;
43084308
Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." },
43094309
Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" },
43104310
Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" },
4311-
Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" },
4311+
Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}." },
4312+
Add_declaration_for_missing_property_0: { code: 90016, category: ts.DiagnosticCategory.Message, key: "Add_declaration_for_missing_property_0_90016", message: "Add declaration for missing property '{0}'." },
4313+
Add_index_signature_for_missing_property_0: { code: 90017, category: ts.DiagnosticCategory.Message, key: "Add_index_signature_for_missing_property_0_90017", message: "Add index signature for missing property '{0}'" },
43124314
Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." },
43134315
Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." },
43144316
};
@@ -21175,6 +21177,8 @@ var ts;
2117521177
getSignaturesOfType: getSignaturesOfType,
2117621178
getIndexTypeOfType: getIndexTypeOfType,
2117721179
getBaseTypes: getBaseTypes,
21180+
getBaseTypeOfLiteralType: getBaseTypeOfLiteralType,
21181+
getWidenedType: getWidenedType,
2117821182
getTypeFromTypeNode: getTypeFromTypeNode,
2117921183
getParameterType: getTypeAtPosition,
2118021184
getReturnTypeOfSignature: getReturnTypeOfSignature,
@@ -59054,7 +59058,7 @@ var ts;
5905459058
var importDecl = importSpecifier.parent;
5905559059
ts.Debug.assert(importDecl.moduleSpecifier === importSpecifier);
5905659060
var defaultName = importDecl.importClause.name;
59057-
var defaultReferencedSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(defaultName));
59061+
var defaultReferencedSymbol = defaultName && checker.getAliasedSymbol(checker.getSymbolAtLocation(defaultName));
5905859062
if (symbol === defaultReferencedSymbol) {
5905959063
return defaultName.text;
5906059064
}
@@ -65647,6 +65651,62 @@ var ts;
6564765651
})(codefix = ts.codefix || (ts.codefix = {}));
6564865652
})(ts || (ts = {}));
6564965653
var ts;
65654+
(function (ts) {
65655+
var codefix;
65656+
(function (codefix) {
65657+
codefix.registerCodeFix({
65658+
errorCodes: [ts.Diagnostics.Property_0_does_not_exist_on_type_1.code],
65659+
getCodeActions: getActionsForAddMissingMember
65660+
});
65661+
function getActionsForAddMissingMember(context) {
65662+
var sourceFile = context.sourceFile;
65663+
var start = context.span.start;
65664+
var token = ts.getTokenAtPosition(sourceFile, start);
65665+
if (token.kind != 70) {
65666+
return undefined;
65667+
}
65668+
var classDeclaration = ts.getContainingClass(token);
65669+
if (!classDeclaration) {
65670+
return undefined;
65671+
}
65672+
if (!(token.parent && token.parent.kind === 178)) {
65673+
return undefined;
65674+
}
65675+
if (token.parent.expression.kind !== 98) {
65676+
return undefined;
65677+
}
65678+
var typeString = "any";
65679+
if (token.parent.parent.kind === 193) {
65680+
var binaryExpression = token.parent.parent;
65681+
var checker = context.program.getTypeChecker();
65682+
var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(binaryExpression.right)));
65683+
typeString = checker.typeToString(widenedType);
65684+
}
65685+
var startPos = classDeclaration.members.pos;
65686+
return [{
65687+
description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Add_declaration_for_missing_property_0), [token.getText()]),
65688+
changes: [{
65689+
fileName: sourceFile.fileName,
65690+
textChanges: [{
65691+
span: { start: startPos, length: 0 },
65692+
newText: token.getFullText(sourceFile) + ": " + typeString + ";"
65693+
}]
65694+
}]
65695+
},
65696+
{
65697+
description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Add_index_signature_for_missing_property_0), [token.getText()]),
65698+
changes: [{
65699+
fileName: sourceFile.fileName,
65700+
textChanges: [{
65701+
span: { start: startPos, length: 0 },
65702+
newText: "[name: string]: " + typeString + ";"
65703+
}]
65704+
}]
65705+
}];
65706+
}
65707+
})(codefix = ts.codefix || (ts.codefix = {}));
65708+
})(ts || (ts = {}));
65709+
var ts;
6565065710
(function (ts) {
6565165711
var codefix;
6565265712
(function (codefix) {
@@ -66456,7 +66516,7 @@ var ts;
6645666516
}
6645766517
var declaration = declarations[0];
6645866518
var name = declaration.name ? declaration.name.getText() : undefined;
66459-
var visibility = getVisibilityPrefix(ts.getModifierFlags(declaration));
66519+
var visibility = getVisibilityPrefixWithSpace(ts.getModifierFlags(declaration));
6646066520
switch (declaration.kind) {
6646166521
case 152:
6646266522
case 153:
@@ -66473,7 +66533,7 @@ var ts;
6647366533
if (declarations.length === 1) {
6647466534
ts.Debug.assert(signatures.length === 1);
6647566535
var sigString_1 = checker.signatureToString(signatures[0], enclosingDeclaration, 2048, 0);
66476-
return "" + visibility + name + sigString_1 + getMethodBodyStub(newlineChar);
66536+
return getStubbedMethod(visibility, name, sigString_1, newlineChar);
6647766537
}
6647866538
var result = "";
6647966539
for (var i = 0; i < signatures.length; i++) {
@@ -66489,7 +66549,7 @@ var ts;
6648966549
bodySig = createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker);
6649066550
}
6649166551
var sigString = checker.signatureToString(bodySig, enclosingDeclaration, 2048, 0);
66492-
result += "" + visibility + name + sigString + getMethodBodyStub(newlineChar);
66552+
result += getStubbedMethod(visibility, name, sigString, newlineChar);
6649366553
return result;
6649466554
default:
6649566555
return "";
@@ -66538,10 +66598,15 @@ var ts;
6653866598
return newParameter;
6653966599
}
6654066600
}
66541-
function getMethodBodyStub(newLineChar) {
66542-
return " {" + newLineChar + "throw new Error('Method not implemented.');" + newLineChar + "}" + newLineChar;
66601+
function getStubbedMethod(visibility, name, sigString, newlineChar) {
66602+
if (sigString === void 0) { sigString = "()"; }
66603+
return "" + visibility + name + sigString + getMethodBodyStub(newlineChar);
66604+
}
66605+
codefix.getStubbedMethod = getStubbedMethod;
66606+
function getMethodBodyStub(newlineChar) {
66607+
return " {" + newlineChar + "throw new Error('Method not implemented.');" + newlineChar + "}" + newlineChar;
6654366608
}
66544-
function getVisibilityPrefix(flags) {
66609+
function getVisibilityPrefixWithSpace(flags) {
6654566610
if (flags & 4) {
6654666611
return "public ";
6654766612
}

lib/tsserverlibrary.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,6 +1564,8 @@ declare namespace ts {
15641564
getSignaturesOfType(type: Type, kind: SignatureKind): Signature[];
15651565
getIndexTypeOfType(type: Type, kind: IndexKind): Type;
15661566
getBaseTypes(type: InterfaceType): BaseType[];
1567+
getBaseTypeOfLiteralType(type: Type): Type;
1568+
getWidenedType(type: Type): Type;
15671569
getReturnTypeOfSignature(signature: Signature): Type;
15681570
getNonNullableType(type: Type): Type;
15691571
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];

0 commit comments

Comments
 (0)