mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge remote-tracking branch 'origin/master' into correctCommentsScaffolding
This commit is contained in:
@@ -13475,13 +13475,14 @@ namespace ts {
|
||||
const containingClass = getContainingClass(node);
|
||||
if (containingClass) {
|
||||
const containingType = getTypeOfNode(containingClass);
|
||||
const baseTypes = getBaseTypes(<InterfaceType>containingType);
|
||||
if (baseTypes.length) {
|
||||
let baseTypes = getBaseTypes(containingType as InterfaceType);
|
||||
while (baseTypes.length) {
|
||||
const baseType = baseTypes[0];
|
||||
if (modifiers & ModifierFlags.Protected &&
|
||||
baseType.symbol === declaration.parent.symbol) {
|
||||
return true;
|
||||
}
|
||||
baseTypes = getBaseTypes(baseType as InterfaceType);
|
||||
}
|
||||
}
|
||||
if (modifiers & ModifierFlags.Private) {
|
||||
@@ -16207,7 +16208,7 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const onfulfilledParameterType = getTypeWithFacts(getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)), TypeFacts.NEUndefined);
|
||||
const onfulfilledParameterType = getTypeWithFacts(getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)), TypeFacts.NEUndefinedOrNull);
|
||||
if (isTypeAny(onfulfilledParameterType)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -863,24 +863,6 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduce the properties defined on a map-like (but not from its prototype chain).
|
||||
*
|
||||
* NOTE: This is intended for use with MapLike<T> objects. For Map<T> objects, use
|
||||
* reduceProperties instead as it offers better performance.
|
||||
*
|
||||
* @param map The map-like to reduce
|
||||
* @param callback An aggregation function that is called for each entry in the map
|
||||
* @param initial The initial value for the reduction.
|
||||
*/
|
||||
export function reduceOwnProperties<T, U>(map: MapLike<T>, callback: (aggregate: U, value: T, key: string) => U, initial: U): U {
|
||||
let result = initial;
|
||||
for (const key in map) if (hasOwnProperty.call(map, key)) {
|
||||
result = callback(result, map[key], String(key));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a shallow equality comparison of the contents of two map-likes.
|
||||
*
|
||||
|
||||
@@ -427,7 +427,7 @@ namespace ts {
|
||||
|
||||
encodeLastRecordedSourceMapSpan();
|
||||
|
||||
return stringify({
|
||||
return JSON.stringify({
|
||||
version: 3,
|
||||
file: sourceMapData.sourceMapFile,
|
||||
sourceRoot: sourceMapData.sourceMapSourceRoot,
|
||||
|
||||
@@ -1223,11 +1223,12 @@ namespace ts {
|
||||
}
|
||||
|
||||
const { firstAccessor, secondAccessor, setAccessor } = getAllAccessorDeclarations(node.members, accessor);
|
||||
if (accessor !== firstAccessor) {
|
||||
const firstAccessorWithDecorators = firstAccessor.decorators ? firstAccessor : secondAccessor && secondAccessor.decorators ? secondAccessor : undefined;
|
||||
if (!firstAccessorWithDecorators || accessor !== firstAccessorWithDecorators) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const decorators = firstAccessor.decorators || (secondAccessor && secondAccessor.decorators);
|
||||
const decorators = firstAccessorWithDecorators.decorators;
|
||||
const parameters = getDecoratorsOfParameters(setAccessor);
|
||||
if (!decorators && !parameters) {
|
||||
return undefined;
|
||||
|
||||
@@ -3189,55 +3189,6 @@ namespace ts {
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize an object graph into a JSON string. This is intended only for use on an acyclic graph
|
||||
* as the fallback implementation does not check for circular references by default.
|
||||
*/
|
||||
export const stringify: (value: any) => string = typeof JSON !== "undefined" && JSON.stringify
|
||||
? JSON.stringify
|
||||
: stringifyFallback;
|
||||
|
||||
/**
|
||||
* Serialize an object graph into a JSON string.
|
||||
*/
|
||||
function stringifyFallback(value: any): string {
|
||||
// JSON.stringify returns `undefined` here, instead of the string "undefined".
|
||||
return value === undefined ? undefined : stringifyValue(value);
|
||||
}
|
||||
|
||||
function stringifyValue(value: any): string {
|
||||
return typeof value === "string" ? `"${escapeString(value)}"`
|
||||
: typeof value === "number" ? isFinite(value) ? String(value) : "null"
|
||||
: typeof value === "boolean" ? value ? "true" : "false"
|
||||
: typeof value === "object" && value ? isArray(value) ? cycleCheck(stringifyArray, value) : cycleCheck(stringifyObject, value)
|
||||
: /*fallback*/ "null";
|
||||
}
|
||||
|
||||
function cycleCheck(cb: (value: any) => string, value: any) {
|
||||
Debug.assert(!value.hasOwnProperty("__cycle"), "Converting circular structure to JSON");
|
||||
value.__cycle = true;
|
||||
const result = cb(value);
|
||||
delete value.__cycle;
|
||||
return result;
|
||||
}
|
||||
|
||||
function stringifyArray(value: any) {
|
||||
return `[${reduceLeft(value, stringifyElement, "")}]`;
|
||||
}
|
||||
|
||||
function stringifyElement(memo: string, value: any) {
|
||||
return (memo ? memo + "," : memo) + stringifyValue(value);
|
||||
}
|
||||
|
||||
function stringifyObject(value: any) {
|
||||
return `{${reduceOwnProperties(value, stringifyProperty, "")}}`;
|
||||
}
|
||||
|
||||
function stringifyProperty(memo: string, value: any, key: string) {
|
||||
return value === undefined || typeof value === "function" || key === "__cycle" ? memo
|
||||
: (memo ? memo + "," : memo) + `"${escapeString(key)}":${stringifyValue(value)}`;
|
||||
}
|
||||
|
||||
const base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||
|
||||
/**
|
||||
|
||||
@@ -607,23 +607,13 @@ namespace FourSlash {
|
||||
});
|
||||
}
|
||||
|
||||
public verifyMemberListContains(symbol: string, text?: string, documentation?: string, kind?: string) {
|
||||
const members = this.getMemberListAtCaret();
|
||||
if (members) {
|
||||
this.assertItemInCompletionList(members.entries, symbol, text, documentation, kind);
|
||||
}
|
||||
else {
|
||||
this.raiseError("Expected a member list, but none was provided");
|
||||
}
|
||||
}
|
||||
|
||||
public verifyMemberListCount(expectedCount: number, negative: boolean) {
|
||||
public verifyCompletionListCount(expectedCount: number, negative: boolean) {
|
||||
if (expectedCount === 0 && negative) {
|
||||
this.verifyMemberListIsEmpty(/*negative*/ false);
|
||||
this.verifyCompletionListIsEmpty(/*negative*/ false);
|
||||
return;
|
||||
}
|
||||
|
||||
const members = this.getMemberListAtCaret();
|
||||
const members = this.getCompletionListAtCaret();
|
||||
|
||||
if (members) {
|
||||
const match = members.entries.length === expectedCount;
|
||||
@@ -637,13 +627,6 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public verifyMemberListDoesNotContain(symbol: string) {
|
||||
const members = this.getMemberListAtCaret();
|
||||
if (members && members.entries.filter(e => e.name === symbol).length !== 0) {
|
||||
this.raiseError(`Member list did contain ${symbol}`);
|
||||
}
|
||||
}
|
||||
|
||||
public verifyCompletionListItemsCountIsGreaterThan(count: number, negative: boolean) {
|
||||
const completions = this.getCompletionListAtCaret();
|
||||
const itemsCount = completions.entries.length;
|
||||
@@ -685,16 +668,6 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public verifyMemberListIsEmpty(negative: boolean) {
|
||||
const members = this.getMemberListAtCaret();
|
||||
if ((!members || members.entries.length === 0) && negative) {
|
||||
this.raiseError("Member list is empty at Caret");
|
||||
}
|
||||
else if ((members && members.entries.length !== 0) && !negative) {
|
||||
this.raiseError(`Member list is not empty at Caret:\nMember List contains: ${stringify(members.entries.map(e => e.name))}`);
|
||||
}
|
||||
}
|
||||
|
||||
public verifyCompletionListIsEmpty(negative: boolean) {
|
||||
const completions = this.getCompletionListAtCaret();
|
||||
if ((!completions || completions.entries.length === 0) && negative) {
|
||||
@@ -892,10 +865,6 @@ namespace FourSlash {
|
||||
this.raiseError(`verifyReferencesAtPositionListContains failed - could not find the item: ${stringify(missingItem)} in the returned list: (${stringify(references)})`);
|
||||
}
|
||||
|
||||
private getMemberListAtCaret() {
|
||||
return this.languageService.getCompletionsAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
}
|
||||
|
||||
private getCompletionListAtCaret() {
|
||||
return this.languageService.getCompletionsAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
}
|
||||
@@ -1353,11 +1322,6 @@ namespace FourSlash {
|
||||
Harness.IO.log(stringify(sigHelp));
|
||||
}
|
||||
|
||||
public printMemberListMembers() {
|
||||
const members = this.getMemberListAtCaret();
|
||||
this.printMembersOrCompletions(members);
|
||||
}
|
||||
|
||||
public printCompletionListMembers() {
|
||||
const completions = this.getCompletionListAtCaret();
|
||||
this.printMembersOrCompletions(completions);
|
||||
@@ -3061,19 +3025,8 @@ namespace FourSlashInterface {
|
||||
}
|
||||
}
|
||||
|
||||
// Verifies the member list contains the specified symbol. The
|
||||
// member list is brought up if necessary
|
||||
public memberListContains(symbol: string, text?: string, documentation?: string, kind?: string) {
|
||||
if (this.negative) {
|
||||
this.state.verifyMemberListDoesNotContain(symbol);
|
||||
}
|
||||
else {
|
||||
this.state.verifyMemberListContains(symbol, text, documentation, kind);
|
||||
}
|
||||
}
|
||||
|
||||
public memberListCount(expectedCount: number) {
|
||||
this.state.verifyMemberListCount(expectedCount, this.negative);
|
||||
public completionListCount(expectedCount: number) {
|
||||
this.state.verifyCompletionListCount(expectedCount, this.negative);
|
||||
}
|
||||
|
||||
// Verifies the completion list contains the specified symbol. The
|
||||
@@ -3109,10 +3062,6 @@ namespace FourSlashInterface {
|
||||
this.state.verifyCompletionListAllowsNewIdentifier(this.negative);
|
||||
}
|
||||
|
||||
public memberListIsEmpty() {
|
||||
this.state.verifyMemberListIsEmpty(this.negative);
|
||||
}
|
||||
|
||||
public signatureHelpPresent() {
|
||||
this.state.verifySignatureHelpPresent(!this.negative);
|
||||
}
|
||||
@@ -3514,10 +3463,6 @@ namespace FourSlashInterface {
|
||||
this.state.printCurrentSignatureHelp();
|
||||
}
|
||||
|
||||
public printMemberListMembers() {
|
||||
this.state.printMemberListMembers();
|
||||
}
|
||||
|
||||
public printCompletionListMembers() {
|
||||
this.state.printCompletionListMembers();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user