Skip to content

Commit

Permalink
Update LKG
Browse files Browse the repository at this point in the history
  • Loading branch information
mhegazy committed Feb 18, 2017
1 parent 1120971 commit a29e8cf
Show file tree
Hide file tree
Showing 12 changed files with 319 additions and 37 deletions.
2 changes: 1 addition & 1 deletion lib/lib.d.ts
Expand Up @@ -160,7 +160,7 @@ interface ObjectConstructor {
* Creates an object that has the specified prototype or that has null prototype.
* @param o Object to use as a prototype. May be null.
*/
create<T extends object>(o: T | null): T | object;
create(o: object | null): any;

/**
* Creates an object that has the specified prototype, and that optionally contains specified properties.
Expand Down
2 changes: 1 addition & 1 deletion lib/lib.es5.d.ts
Expand Up @@ -160,7 +160,7 @@ interface ObjectConstructor {
* Creates an object that has the specified prototype or that has null prototype.
* @param o Object to use as a prototype. May be null.
*/
create<T extends object>(o: T | null): T | object;
create(o: object | null): any;

/**
* Creates an object that has the specified prototype, and that optionally contains specified properties.
Expand Down
2 changes: 1 addition & 1 deletion lib/lib.es6.d.ts
Expand Up @@ -160,7 +160,7 @@ interface ObjectConstructor {
* Creates an object that has the specified prototype or that has null prototype.
* @param o Object to use as a prototype. May be null.
*/
create<T extends object>(o: T | null): T | object;
create(o: object | null): any;

/**
* Creates an object that has the specified prototype, and that optionally contains specified properties.
Expand Down
6 changes: 5 additions & 1 deletion lib/tsc.js
Expand Up @@ -3347,7 +3347,9 @@ var ts;
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." },
Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" },
Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" },
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}" },
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}." },
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}'." },
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}'" },
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}'." },
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}'." },
};
Expand Down Expand Up @@ -20115,6 +20117,8 @@ var ts;
getSignaturesOfType: getSignaturesOfType,
getIndexTypeOfType: getIndexTypeOfType,
getBaseTypes: getBaseTypes,
getBaseTypeOfLiteralType: getBaseTypeOfLiteralType,
getWidenedType: getWidenedType,
getTypeFromTypeNode: getTypeFromTypeNode,
getParameterType: getTypeAtPosition,
getReturnTypeOfSignature: getReturnTypeOfSignature,
Expand Down
81 changes: 73 additions & 8 deletions lib/tsserver.js
Expand Up @@ -4308,7 +4308,9 @@ var ts;
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." },
Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" },
Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" },
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}" },
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}." },
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}'." },
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}'" },
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}'." },
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}'." },
};
Expand Down Expand Up @@ -21175,6 +21177,8 @@ var ts;
getSignaturesOfType: getSignaturesOfType,
getIndexTypeOfType: getIndexTypeOfType,
getBaseTypes: getBaseTypes,
getBaseTypeOfLiteralType: getBaseTypeOfLiteralType,
getWidenedType: getWidenedType,
getTypeFromTypeNode: getTypeFromTypeNode,
getParameterType: getTypeAtPosition,
getReturnTypeOfSignature: getReturnTypeOfSignature,
Expand Down Expand Up @@ -59054,7 +59058,7 @@ var ts;
var importDecl = importSpecifier.parent;
ts.Debug.assert(importDecl.moduleSpecifier === importSpecifier);
var defaultName = importDecl.importClause.name;
var defaultReferencedSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(defaultName));
var defaultReferencedSymbol = defaultName && checker.getAliasedSymbol(checker.getSymbolAtLocation(defaultName));
if (symbol === defaultReferencedSymbol) {
return defaultName.text;
}
Expand Down Expand Up @@ -65647,6 +65651,62 @@ var ts;
})(codefix = ts.codefix || (ts.codefix = {}));
})(ts || (ts = {}));
var ts;
(function (ts) {
var codefix;
(function (codefix) {
codefix.registerCodeFix({
errorCodes: [ts.Diagnostics.Property_0_does_not_exist_on_type_1.code],
getCodeActions: getActionsForAddMissingMember
});
function getActionsForAddMissingMember(context) {
var sourceFile = context.sourceFile;
var start = context.span.start;
var token = ts.getTokenAtPosition(sourceFile, start);
if (token.kind != 70) {
return undefined;
}
var classDeclaration = ts.getContainingClass(token);
if (!classDeclaration) {
return undefined;
}
if (!(token.parent && token.parent.kind === 178)) {
return undefined;
}
if (token.parent.expression.kind !== 98) {
return undefined;
}
var typeString = "any";
if (token.parent.parent.kind === 193) {
var binaryExpression = token.parent.parent;
var checker = context.program.getTypeChecker();
var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(binaryExpression.right)));
typeString = checker.typeToString(widenedType);
}
var startPos = classDeclaration.members.pos;
return [{
description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Add_declaration_for_missing_property_0), [token.getText()]),
changes: [{
fileName: sourceFile.fileName,
textChanges: [{
span: { start: startPos, length: 0 },
newText: token.getFullText(sourceFile) + ": " + typeString + ";"
}]
}]
},
{
description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Add_index_signature_for_missing_property_0), [token.getText()]),
changes: [{
fileName: sourceFile.fileName,
textChanges: [{
span: { start: startPos, length: 0 },
newText: "[name: string]: " + typeString + ";"
}]
}]
}];
}
})(codefix = ts.codefix || (ts.codefix = {}));
})(ts || (ts = {}));
var ts;
(function (ts) {
var codefix;
(function (codefix) {
Expand Down Expand Up @@ -66456,7 +66516,7 @@ var ts;
}
var declaration = declarations[0];
var name = declaration.name ? declaration.name.getText() : undefined;
var visibility = getVisibilityPrefix(ts.getModifierFlags(declaration));
var visibility = getVisibilityPrefixWithSpace(ts.getModifierFlags(declaration));
switch (declaration.kind) {
case 152:
case 153:
Expand All @@ -66473,7 +66533,7 @@ var ts;
if (declarations.length === 1) {
ts.Debug.assert(signatures.length === 1);
var sigString_1 = checker.signatureToString(signatures[0], enclosingDeclaration, 2048, 0);
return "" + visibility + name + sigString_1 + getMethodBodyStub(newlineChar);
return getStubbedMethod(visibility, name, sigString_1, newlineChar);
}
var result = "";
for (var i = 0; i < signatures.length; i++) {
Expand All @@ -66489,7 +66549,7 @@ var ts;
bodySig = createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker);
}
var sigString = checker.signatureToString(bodySig, enclosingDeclaration, 2048, 0);
result += "" + visibility + name + sigString + getMethodBodyStub(newlineChar);
result += getStubbedMethod(visibility, name, sigString, newlineChar);
return result;
default:
return "";
Expand Down Expand Up @@ -66538,10 +66598,15 @@ var ts;
return newParameter;
}
}
function getMethodBodyStub(newLineChar) {
return " {" + newLineChar + "throw new Error('Method not implemented.');" + newLineChar + "}" + newLineChar;
function getStubbedMethod(visibility, name, sigString, newlineChar) {
if (sigString === void 0) { sigString = "()"; }
return "" + visibility + name + sigString + getMethodBodyStub(newlineChar);
}
codefix.getStubbedMethod = getStubbedMethod;
function getMethodBodyStub(newlineChar) {
return " {" + newlineChar + "throw new Error('Method not implemented.');" + newlineChar + "}" + newlineChar;
}
function getVisibilityPrefix(flags) {
function getVisibilityPrefixWithSpace(flags) {
if (flags & 4) {
return "public ";
}
Expand Down
2 changes: 2 additions & 0 deletions lib/tsserverlibrary.d.ts
Expand Up @@ -1564,6 +1564,8 @@ declare namespace ts {
getSignaturesOfType(type: Type, kind: SignatureKind): Signature[];
getIndexTypeOfType(type: Type, kind: IndexKind): Type;
getBaseTypes(type: InterfaceType): BaseType[];
getBaseTypeOfLiteralType(type: Type): Type;
getWidenedType(type: Type): Type;
getReturnTypeOfSignature(signature: Signature): Type;
getNonNullableType(type: Type): Type;
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
Expand Down

0 comments on commit a29e8cf

Please sign in to comment.