Merge branch 'master' into master-refactorJsDocTest
This commit is contained in:
commit
7815ccff1c
|
@ -6510,7 +6510,7 @@ namespace ts {
|
|||
case "arg":
|
||||
case "argument":
|
||||
case "param":
|
||||
tag = parseParamTag(atToken, tagName);
|
||||
tag = parseParameterOrPropertyTag(atToken, tagName, /*shouldParseParamTag*/ true);
|
||||
break;
|
||||
case "return":
|
||||
case "returns":
|
||||
|
@ -6655,11 +6655,12 @@ namespace ts {
|
|||
return { name, isBracketed };
|
||||
}
|
||||
|
||||
function parseParamTag(atToken: AtToken, tagName: Identifier) {
|
||||
function parseParameterOrPropertyTag(atToken: AtToken, tagName: Identifier, shouldParseParamTag: boolean): JSDocPropertyTag | JSDocParameterTag {
|
||||
let typeExpression = tryParseTypeExpression();
|
||||
skipWhitespace();
|
||||
|
||||
const { name, isBracketed } = parseBracketNameInPropertyAndParamTag();
|
||||
skipWhitespace();
|
||||
|
||||
if (!name) {
|
||||
parseErrorAtPosition(scanner.getStartPos(), 0, Diagnostics.Identifier_expected);
|
||||
|
@ -6678,13 +6679,15 @@ namespace ts {
|
|||
typeExpression = tryParseTypeExpression();
|
||||
}
|
||||
|
||||
const result = <JSDocParameterTag>createNode(SyntaxKind.JSDocParameterTag, atToken.pos);
|
||||
const result = shouldParseParamTag ?
|
||||
<JSDocParameterTag>createNode(SyntaxKind.JSDocParameterTag, atToken.pos) :
|
||||
<JSDocPropertyTag>createNode(SyntaxKind.JSDocPropertyTag, atToken.pos);
|
||||
result.atToken = atToken;
|
||||
result.tagName = tagName;
|
||||
result.preParameterName = preName;
|
||||
result.typeExpression = typeExpression;
|
||||
result.postParameterName = postName;
|
||||
result.parameterName = postName || preName;
|
||||
result.name = postName || preName;
|
||||
result.isBracketed = isBracketed;
|
||||
return finishNode(result);
|
||||
}
|
||||
|
@ -6713,26 +6716,6 @@ namespace ts {
|
|||
return finishNode(result);
|
||||
}
|
||||
|
||||
function parsePropertyTag(atToken: AtToken, tagName: Identifier): JSDocPropertyTag {
|
||||
const typeExpression = tryParseTypeExpression();
|
||||
skipWhitespace();
|
||||
const { name, isBracketed } = parseBracketNameInPropertyAndParamTag();
|
||||
skipWhitespace();
|
||||
|
||||
if (!name) {
|
||||
parseErrorAtPosition(scanner.getStartPos(), /*length*/ 0, Diagnostics.Identifier_expected);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const result = <JSDocPropertyTag>createNode(SyntaxKind.JSDocPropertyTag, atToken.pos);
|
||||
result.atToken = atToken;
|
||||
result.tagName = tagName;
|
||||
result.name = name;
|
||||
result.typeExpression = typeExpression;
|
||||
result.isBracketed = isBracketed;
|
||||
return finishNode(result);
|
||||
}
|
||||
|
||||
function parseAugmentsTag(atToken: AtToken, tagName: Identifier): JSDocAugmentsTag {
|
||||
const typeExpression = tryParseTypeExpression();
|
||||
|
||||
|
@ -6869,7 +6852,7 @@ namespace ts {
|
|||
return true;
|
||||
case "prop":
|
||||
case "property":
|
||||
const propertyTag = parsePropertyTag(atToken, tagName);
|
||||
const propertyTag = parseParameterOrPropertyTag(atToken, tagName, /*shouldParseParamTag*/ false) as JSDocPropertyTag;
|
||||
if (propertyTag) {
|
||||
if (!parentTag.jsDocPropertyTags) {
|
||||
parentTag.jsDocPropertyTags = <NodeArray<JSDocPropertyTag>>[];
|
||||
|
|
|
@ -429,6 +429,7 @@ namespace ts {
|
|||
case CharacterCodes.slash:
|
||||
// starts of normal trivia
|
||||
case CharacterCodes.lessThan:
|
||||
case CharacterCodes.bar:
|
||||
case CharacterCodes.equals:
|
||||
case CharacterCodes.greaterThan:
|
||||
// Starts of conflict marker trivia
|
||||
|
@ -496,6 +497,7 @@ namespace ts {
|
|||
break;
|
||||
|
||||
case CharacterCodes.lessThan:
|
||||
case CharacterCodes.bar:
|
||||
case CharacterCodes.equals:
|
||||
case CharacterCodes.greaterThan:
|
||||
if (isConflictMarkerTrivia(text, pos)) {
|
||||
|
@ -562,12 +564,12 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
else {
|
||||
Debug.assert(ch === CharacterCodes.equals);
|
||||
// Consume everything from the start of the mid-conflict marker to the start of the next
|
||||
// end-conflict marker.
|
||||
Debug.assert(ch === CharacterCodes.bar || ch === CharacterCodes.equals);
|
||||
// Consume everything from the start of a ||||||| or ======= marker to the start
|
||||
// of the next ======= or >>>>>>> marker.
|
||||
while (pos < len) {
|
||||
const ch = text.charCodeAt(pos);
|
||||
if (ch === CharacterCodes.greaterThan && isConflictMarkerTrivia(text, pos)) {
|
||||
const currentChar = text.charCodeAt(pos);
|
||||
if ((currentChar === CharacterCodes.equals || currentChar === CharacterCodes.greaterThan) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1562,6 +1564,16 @@ namespace ts {
|
|||
pos++;
|
||||
return token = SyntaxKind.OpenBraceToken;
|
||||
case CharacterCodes.bar:
|
||||
if (isConflictMarkerTrivia(text, pos)) {
|
||||
pos = scanConflictMarkerTrivia(text, pos, error);
|
||||
if (skipTrivia) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
return token = SyntaxKind.ConflictMarkerTrivia;
|
||||
}
|
||||
}
|
||||
|
||||
if (text.charCodeAt(pos + 1) === CharacterCodes.bar) {
|
||||
return pos += 2, token = SyntaxKind.BarBarToken;
|
||||
}
|
||||
|
|
|
@ -2145,6 +2145,10 @@ namespace ts {
|
|||
parent: JSDoc;
|
||||
kind: SyntaxKind.JSDocPropertyTag;
|
||||
name: Identifier;
|
||||
/** the parameter name, if provided *before* the type (TypeScript-style) */
|
||||
preParameterName?: Identifier;
|
||||
/** the parameter name, if provided *after* the type (JSDoc-standard) */
|
||||
postParameterName?: Identifier;
|
||||
typeExpression: JSDocTypeExpression;
|
||||
isBracketed: boolean;
|
||||
}
|
||||
|
@ -2163,7 +2167,7 @@ namespace ts {
|
|||
/** the parameter name, if provided *after* the type (JSDoc-standard) */
|
||||
postParameterName?: Identifier;
|
||||
/** the parameter name, regardless of the location it was provided */
|
||||
parameterName: Identifier;
|
||||
name: Identifier;
|
||||
isBracketed: boolean;
|
||||
}
|
||||
|
||||
|
|
|
@ -1635,7 +1635,7 @@ namespace ts {
|
|||
}
|
||||
else if (param.name.kind === SyntaxKind.Identifier) {
|
||||
const name = (param.name as Identifier).text;
|
||||
return filter(tags, tag => tag.kind === SyntaxKind.JSDocParameterTag && tag.parameterName.text === name);
|
||||
return filter(tags, tag => tag.kind === SyntaxKind.JSDocParameterTag && tag.name.text === name);
|
||||
}
|
||||
else {
|
||||
// TODO: it's a destructured parameter, so it should look up an "object type" series of multiple lines
|
||||
|
@ -1646,7 +1646,7 @@ namespace ts {
|
|||
|
||||
/** Does the opposite of `getJSDocParameterTags`: given a JSDoc parameter, finds the parameter corresponding to it. */
|
||||
export function getParameterFromJSDoc(node: JSDocParameterTag): ParameterDeclaration | undefined {
|
||||
const name = node.parameterName.text;
|
||||
const name = node.name.text;
|
||||
const grandParent = node.parent!.parent!;
|
||||
Debug.assert(node.parent!.kind === SyntaxKind.JSDocComment);
|
||||
if (!isFunctionLike(grandParent)) {
|
||||
|
|
|
@ -424,6 +424,50 @@ class D { }\r\n\
|
|||
comment("=======\r\nclass D { }\r\n"),
|
||||
comment(">>>>>>> Branch - a"),
|
||||
finalEndOfLineState(ts.EndOfLineState.None));
|
||||
|
||||
testLexicalClassification(
|
||||
"class C {\r\n\
|
||||
<<<<<<< HEAD\r\n\
|
||||
v = 1;\r\n\
|
||||
||||||| merged common ancestors\r\n\
|
||||
v = 3;\r\n\
|
||||
=======\r\n\
|
||||
v = 2;\r\n\
|
||||
>>>>>>> Branch - a\r\n\
|
||||
}",
|
||||
ts.EndOfLineState.None,
|
||||
keyword("class"),
|
||||
identifier("C"),
|
||||
punctuation("{"),
|
||||
comment("<<<<<<< HEAD"),
|
||||
identifier("v"),
|
||||
operator("="),
|
||||
numberLiteral("1"),
|
||||
punctuation(";"),
|
||||
comment("||||||| merged common ancestors\r\n v = 3;\r\n"),
|
||||
comment("=======\r\n v = 2;\r\n"),
|
||||
comment(">>>>>>> Branch - a"),
|
||||
punctuation("}"),
|
||||
finalEndOfLineState(ts.EndOfLineState.None));
|
||||
|
||||
testLexicalClassification(
|
||||
"<<<<<<< HEAD\r\n\
|
||||
class C { }\r\n\
|
||||
||||||| merged common ancestors\r\n\
|
||||
class E { }\r\n\
|
||||
=======\r\n\
|
||||
class D { }\r\n\
|
||||
>>>>>>> Branch - a\r\n",
|
||||
ts.EndOfLineState.None,
|
||||
comment("<<<<<<< HEAD"),
|
||||
keyword("class"),
|
||||
identifier("C"),
|
||||
punctuation("{"),
|
||||
punctuation("}"),
|
||||
comment("||||||| merged common ancestors\r\nclass E { }\r\n"),
|
||||
comment("=======\r\nclass D { }\r\n"),
|
||||
comment(">>>>>>> Branch - a"),
|
||||
finalEndOfLineState(ts.EndOfLineState.None));
|
||||
});
|
||||
|
||||
it("'of' keyword", function () {
|
||||
|
|
|
@ -85,6 +85,11 @@ namespace ts.server.typingsInstaller {
|
|||
throttleLimit,
|
||||
log);
|
||||
this.npmPath = npmLocation !== undefined ? npmLocation : getDefaultNPMLocation(process.argv[0]);
|
||||
|
||||
// If the NPM path contains spaces and isn't wrapped in quotes, do so.
|
||||
if (this.npmPath.indexOf(" ") !== -1 && this.npmPath[0] !== `"`) {
|
||||
this.npmPath = `"${this.npmPath}"`;
|
||||
}
|
||||
if (this.log.isEnabled()) {
|
||||
this.log.writeLine(`Process id: ${process.pid}`);
|
||||
this.log.writeLine(`NPM location: ${this.npmPath} (explicit '${Arguments.NpmLocation}' ${npmLocation === undefined ? "not " : ""} provided)`);
|
||||
|
@ -186,4 +191,4 @@ namespace ts.server.typingsInstaller {
|
|||
});
|
||||
const installer = new NodeTypingsInstaller(globalTypingsCacheLocation, typingSafeListLocation, npmLocation, /*throttleLimit*/5, log);
|
||||
installer.listen();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -685,9 +685,9 @@ namespace ts {
|
|||
continue;
|
||||
}
|
||||
|
||||
// for the ======== add a comment for the first line, and then lex all
|
||||
// subsequent lines up until the end of the conflict marker.
|
||||
Debug.assert(ch === CharacterCodes.equals);
|
||||
// for the ||||||| and ======== markers, add a comment for the first line,
|
||||
// and then lex all subsequent lines up until the end of the conflict marker.
|
||||
Debug.assert(ch === CharacterCodes.bar || ch === CharacterCodes.equals);
|
||||
classifyDisabledMergeCode(text, start, end);
|
||||
}
|
||||
}
|
||||
|
@ -782,8 +782,8 @@ namespace ts {
|
|||
}
|
||||
|
||||
function classifyDisabledMergeCode(text: string, start: number, end: number) {
|
||||
// Classify the line that the ======= marker is on as a comment. Then just lex
|
||||
// all further tokens and add them to the result.
|
||||
// Classify the line that the ||||||| or ======= marker is on as a comment.
|
||||
// Then just lex all further tokens and add them to the result.
|
||||
let i: number;
|
||||
for (i = start; i < end; i++) {
|
||||
if (isLineBreak(text.charCodeAt(i))) {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"0": {
|
||||
"kind": "JSDocParameterTag",
|
||||
"pos": 8,
|
||||
"end": 27,
|
||||
"end": 28,
|
||||
"atToken": {
|
||||
"kind": "AtToken",
|
||||
"pos": 8,
|
||||
|
@ -34,7 +34,7 @@
|
|||
"end": 27,
|
||||
"text": "name1"
|
||||
},
|
||||
"parameterName": {
|
||||
"name": {
|
||||
"kind": "Identifier",
|
||||
"pos": 22,
|
||||
"end": 27,
|
||||
|
@ -44,6 +44,6 @@
|
|||
},
|
||||
"length": 1,
|
||||
"pos": 8,
|
||||
"end": 27
|
||||
"end": 28
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
"0": {
|
||||
"kind": "JSDocParameterTag",
|
||||
"pos": 8,
|
||||
"end": 32,
|
||||
"end": 33,
|
||||
"atToken": {
|
||||
"kind": "AtToken",
|
||||
"pos": 8,
|
||||
|
@ -34,7 +34,7 @@
|
|||
"end": 32,
|
||||
"text": "name1"
|
||||
},
|
||||
"parameterName": {
|
||||
"name": {
|
||||
"kind": "Identifier",
|
||||
"pos": 27,
|
||||
"end": 32,
|
||||
|
@ -44,6 +44,6 @@
|
|||
},
|
||||
"length": 1,
|
||||
"pos": 8,
|
||||
"end": 32
|
||||
"end": 33
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
"0": {
|
||||
"kind": "JSDocParameterTag",
|
||||
"pos": 8,
|
||||
"end": 29,
|
||||
"end": 30,
|
||||
"atToken": {
|
||||
"kind": "AtToken",
|
||||
"pos": 8,
|
||||
|
@ -34,7 +34,7 @@
|
|||
"end": 29,
|
||||
"text": "name1"
|
||||
},
|
||||
"parameterName": {
|
||||
"name": {
|
||||
"kind": "Identifier",
|
||||
"pos": 24,
|
||||
"end": 29,
|
||||
|
@ -44,6 +44,6 @@
|
|||
},
|
||||
"length": 1,
|
||||
"pos": 8,
|
||||
"end": 29
|
||||
"end": 30
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
"0": {
|
||||
"kind": "JSDocParameterTag",
|
||||
"pos": 8,
|
||||
"end": 29,
|
||||
"end": 30,
|
||||
"atToken": {
|
||||
"kind": "AtToken",
|
||||
"pos": 8,
|
||||
|
@ -34,7 +34,7 @@
|
|||
"end": 29,
|
||||
"text": "name1"
|
||||
},
|
||||
"parameterName": {
|
||||
"name": {
|
||||
"kind": "Identifier",
|
||||
"pos": 24,
|
||||
"end": 29,
|
||||
|
@ -44,6 +44,6 @@
|
|||
},
|
||||
"length": 1,
|
||||
"pos": 8,
|
||||
"end": 29
|
||||
"end": 30
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@
|
|||
"end": 30,
|
||||
"text": "name1"
|
||||
},
|
||||
"parameterName": {
|
||||
"name": {
|
||||
"kind": "Identifier",
|
||||
"pos": 25,
|
||||
"end": 30,
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
"end": 31,
|
||||
"text": "name1"
|
||||
},
|
||||
"parameterName": {
|
||||
"name": {
|
||||
"kind": "Identifier",
|
||||
"pos": 26,
|
||||
"end": 31,
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
"end": 28
|
||||
}
|
||||
},
|
||||
"parameterName": {
|
||||
"name": {
|
||||
"kind": "Identifier",
|
||||
"pos": 15,
|
||||
"end": 20,
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
"end": 28
|
||||
}
|
||||
},
|
||||
"parameterName": {
|
||||
"name": {
|
||||
"kind": "Identifier",
|
||||
"pos": 15,
|
||||
"end": 20,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"0": {
|
||||
"kind": "JSDocParameterTag",
|
||||
"pos": 8,
|
||||
"end": 18,
|
||||
"end": 19,
|
||||
"atToken": {
|
||||
"kind": "AtToken",
|
||||
"pos": 8,
|
||||
|
@ -24,7 +24,7 @@
|
|||
"end": 18,
|
||||
"text": "foo"
|
||||
},
|
||||
"parameterName": {
|
||||
"name": {
|
||||
"kind": "Identifier",
|
||||
"pos": 15,
|
||||
"end": 18,
|
||||
|
@ -34,6 +34,6 @@
|
|||
},
|
||||
"length": 1,
|
||||
"pos": 8,
|
||||
"end": 18
|
||||
"end": 19
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
"0": {
|
||||
"kind": "JSDocParameterTag",
|
||||
"pos": 8,
|
||||
"end": 29,
|
||||
"end": 32,
|
||||
"atToken": {
|
||||
"kind": "AtToken",
|
||||
"pos": 8,
|
||||
|
@ -34,7 +34,7 @@
|
|||
"end": 29,
|
||||
"text": "name1"
|
||||
},
|
||||
"parameterName": {
|
||||
"name": {
|
||||
"kind": "Identifier",
|
||||
"pos": 24,
|
||||
"end": 29,
|
||||
|
@ -45,7 +45,7 @@
|
|||
"1": {
|
||||
"kind": "JSDocParameterTag",
|
||||
"pos": 34,
|
||||
"end": 55,
|
||||
"end": 56,
|
||||
"atToken": {
|
||||
"kind": "AtToken",
|
||||
"pos": 34,
|
||||
|
@ -73,7 +73,7 @@
|
|||
"end": 55,
|
||||
"text": "name2"
|
||||
},
|
||||
"parameterName": {
|
||||
"name": {
|
||||
"kind": "Identifier",
|
||||
"pos": 50,
|
||||
"end": 55,
|
||||
|
@ -83,6 +83,6 @@
|
|||
},
|
||||
"length": 2,
|
||||
"pos": 8,
|
||||
"end": 55
|
||||
"end": 56
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
"0": {
|
||||
"kind": "JSDocParameterTag",
|
||||
"pos": 8,
|
||||
"end": 29,
|
||||
"end": 30,
|
||||
"atToken": {
|
||||
"kind": "AtToken",
|
||||
"pos": 8,
|
||||
|
@ -34,7 +34,7 @@
|
|||
"end": 29,
|
||||
"text": "name1"
|
||||
},
|
||||
"parameterName": {
|
||||
"name": {
|
||||
"kind": "Identifier",
|
||||
"pos": 24,
|
||||
"end": 29,
|
||||
|
@ -45,7 +45,7 @@
|
|||
"1": {
|
||||
"kind": "JSDocParameterTag",
|
||||
"pos": 30,
|
||||
"end": 51,
|
||||
"end": 52,
|
||||
"atToken": {
|
||||
"kind": "AtToken",
|
||||
"pos": 30,
|
||||
|
@ -73,7 +73,7 @@
|
|||
"end": 51,
|
||||
"text": "name2"
|
||||
},
|
||||
"parameterName": {
|
||||
"name": {
|
||||
"kind": "Identifier",
|
||||
"pos": 46,
|
||||
"end": 51,
|
||||
|
@ -83,6 +83,6 @@
|
|||
},
|
||||
"length": 2,
|
||||
"pos": 8,
|
||||
"end": 51
|
||||
"end": 52
|
||||
}
|
||||
}
|
|
@ -82,12 +82,6 @@
|
|||
"end": 56,
|
||||
"text": "property"
|
||||
},
|
||||
"name": {
|
||||
"kind": "Identifier",
|
||||
"pos": 66,
|
||||
"end": 69,
|
||||
"text": "age"
|
||||
},
|
||||
"typeExpression": {
|
||||
"kind": "JSDocTypeExpression",
|
||||
"pos": 57,
|
||||
|
@ -97,6 +91,18 @@
|
|||
"pos": 58,
|
||||
"end": 64
|
||||
}
|
||||
},
|
||||
"postParameterName": {
|
||||
"kind": "Identifier",
|
||||
"pos": 66,
|
||||
"end": 69,
|
||||
"text": "age"
|
||||
},
|
||||
"name": {
|
||||
"kind": "Identifier",
|
||||
"pos": 66,
|
||||
"end": 69,
|
||||
"text": "age"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -114,12 +120,6 @@
|
|||
"end": 83,
|
||||
"text": "property"
|
||||
},
|
||||
"name": {
|
||||
"kind": "Identifier",
|
||||
"pos": 93,
|
||||
"end": 97,
|
||||
"text": "name"
|
||||
},
|
||||
"typeExpression": {
|
||||
"kind": "JSDocTypeExpression",
|
||||
"pos": 84,
|
||||
|
@ -129,6 +129,18 @@
|
|||
"pos": 85,
|
||||
"end": 91
|
||||
}
|
||||
},
|
||||
"postParameterName": {
|
||||
"kind": "Identifier",
|
||||
"pos": 93,
|
||||
"end": 97,
|
||||
"text": "name"
|
||||
},
|
||||
"name": {
|
||||
"kind": "Identifier",
|
||||
"pos": 93,
|
||||
"end": 97,
|
||||
"text": "name"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -15,6 +15,19 @@ function foo(opts) {
|
|||
|
||||
foo({x: 'abc'});
|
||||
|
||||
/**
|
||||
* @typedef {Object} AnotherOpts
|
||||
* @property anotherX {string}
|
||||
* @property anotherY {string=}
|
||||
*
|
||||
* @param {AnotherOpts} opts
|
||||
*/
|
||||
function foo1(opts) {
|
||||
opts.anotherX;
|
||||
}
|
||||
|
||||
foo1({anotherX: "world"});
|
||||
|
||||
/**
|
||||
* @typedef {object} Opts1
|
||||
* @property {string} x
|
||||
|
@ -24,10 +37,10 @@ foo({x: 'abc'});
|
|||
*
|
||||
* @param {Opts1} opts
|
||||
*/
|
||||
function foo1(opts) {
|
||||
function foo2(opts) {
|
||||
opts.x;
|
||||
}
|
||||
foo1({x: 'abc'});
|
||||
foo2({x: 'abc'});
|
||||
|
||||
|
||||
//// [0.js]
|
||||
|
@ -45,6 +58,17 @@ function foo(opts) {
|
|||
opts.x;
|
||||
}
|
||||
foo({ x: 'abc' });
|
||||
/**
|
||||
* @typedef {Object} AnotherOpts
|
||||
* @property anotherX {string}
|
||||
* @property anotherY {string=}
|
||||
*
|
||||
* @param {AnotherOpts} opts
|
||||
*/
|
||||
function foo1(opts) {
|
||||
opts.anotherX;
|
||||
}
|
||||
foo1({ anotherX: "world" });
|
||||
/**
|
||||
* @typedef {object} Opts1
|
||||
* @property {string} x
|
||||
|
@ -54,7 +78,7 @@ foo({ x: 'abc' });
|
|||
*
|
||||
* @param {Opts1} opts
|
||||
*/
|
||||
function foo1(opts) {
|
||||
function foo2(opts) {
|
||||
opts.x;
|
||||
}
|
||||
foo1({ x: 'abc' });
|
||||
foo2({ x: 'abc' });
|
||||
|
|
|
@ -23,6 +23,27 @@ foo({x: 'abc'});
|
|||
>foo : Symbol(foo, Decl(0.js, 0, 0))
|
||||
>x : Symbol(x, Decl(0.js, 14, 5))
|
||||
|
||||
/**
|
||||
* @typedef {Object} AnotherOpts
|
||||
* @property anotherX {string}
|
||||
* @property anotherY {string=}
|
||||
*
|
||||
* @param {AnotherOpts} opts
|
||||
*/
|
||||
function foo1(opts) {
|
||||
>foo1 : Symbol(foo1, Decl(0.js, 14, 16))
|
||||
>opts : Symbol(opts, Decl(0.js, 23, 14))
|
||||
|
||||
opts.anotherX;
|
||||
>opts.anotherX : Symbol(anotherX, Decl(0.js, 18, 3))
|
||||
>opts : Symbol(opts, Decl(0.js, 23, 14))
|
||||
>anotherX : Symbol(anotherX, Decl(0.js, 18, 3))
|
||||
}
|
||||
|
||||
foo1({anotherX: "world"});
|
||||
>foo1 : Symbol(foo1, Decl(0.js, 14, 16))
|
||||
>anotherX : Symbol(anotherX, Decl(0.js, 27, 6))
|
||||
|
||||
/**
|
||||
* @typedef {object} Opts1
|
||||
* @property {string} x
|
||||
|
@ -32,16 +53,16 @@ foo({x: 'abc'});
|
|||
*
|
||||
* @param {Opts1} opts
|
||||
*/
|
||||
function foo1(opts) {
|
||||
>foo1 : Symbol(foo1, Decl(0.js, 14, 16))
|
||||
>opts : Symbol(opts, Decl(0.js, 25, 14))
|
||||
function foo2(opts) {
|
||||
>foo2 : Symbol(foo2, Decl(0.js, 27, 26))
|
||||
>opts : Symbol(opts, Decl(0.js, 38, 14))
|
||||
|
||||
opts.x;
|
||||
>opts.x : Symbol(x, Decl(0.js, 18, 3))
|
||||
>opts : Symbol(opts, Decl(0.js, 25, 14))
|
||||
>x : Symbol(x, Decl(0.js, 18, 3))
|
||||
>opts.x : Symbol(x, Decl(0.js, 31, 3))
|
||||
>opts : Symbol(opts, Decl(0.js, 38, 14))
|
||||
>x : Symbol(x, Decl(0.js, 31, 3))
|
||||
}
|
||||
foo1({x: 'abc'});
|
||||
>foo1 : Symbol(foo1, Decl(0.js, 14, 16))
|
||||
>x : Symbol(x, Decl(0.js, 28, 6))
|
||||
foo2({x: 'abc'});
|
||||
>foo2 : Symbol(foo2, Decl(0.js, 27, 26))
|
||||
>x : Symbol(x, Decl(0.js, 41, 6))
|
||||
|
||||
|
|
|
@ -26,6 +26,30 @@ foo({x: 'abc'});
|
|||
>x : string
|
||||
>'abc' : "abc"
|
||||
|
||||
/**
|
||||
* @typedef {Object} AnotherOpts
|
||||
* @property anotherX {string}
|
||||
* @property anotherY {string=}
|
||||
*
|
||||
* @param {AnotherOpts} opts
|
||||
*/
|
||||
function foo1(opts) {
|
||||
>foo1 : (opts: { anotherX: string; anotherY?: string; }) => void
|
||||
>opts : { anotherX: string; anotherY?: string; }
|
||||
|
||||
opts.anotherX;
|
||||
>opts.anotherX : string
|
||||
>opts : { anotherX: string; anotherY?: string; }
|
||||
>anotherX : string
|
||||
}
|
||||
|
||||
foo1({anotherX: "world"});
|
||||
>foo1({anotherX: "world"}) : void
|
||||
>foo1 : (opts: { anotherX: string; anotherY?: string; }) => void
|
||||
>{anotherX: "world"} : { anotherX: string; }
|
||||
>anotherX : string
|
||||
>"world" : "world"
|
||||
|
||||
/**
|
||||
* @typedef {object} Opts1
|
||||
* @property {string} x
|
||||
|
@ -35,8 +59,8 @@ foo({x: 'abc'});
|
|||
*
|
||||
* @param {Opts1} opts
|
||||
*/
|
||||
function foo1(opts) {
|
||||
>foo1 : (opts: { x: string; y?: string; z?: string; w?: string; }) => void
|
||||
function foo2(opts) {
|
||||
>foo2 : (opts: { x: string; y?: string; z?: string; w?: string; }) => void
|
||||
>opts : { x: string; y?: string; z?: string; w?: string; }
|
||||
|
||||
opts.x;
|
||||
|
@ -44,9 +68,9 @@ function foo1(opts) {
|
|||
>opts : { x: string; y?: string; z?: string; w?: string; }
|
||||
>x : string
|
||||
}
|
||||
foo1({x: 'abc'});
|
||||
>foo1({x: 'abc'}) : void
|
||||
>foo1 : (opts: { x: string; y?: string; z?: string; w?: string; }) => void
|
||||
foo2({x: 'abc'});
|
||||
>foo2({x: 'abc'}) : void
|
||||
>foo2 : (opts: { x: string; y?: string; z?: string; w?: string; }) => void
|
||||
>{x: 'abc'} : { x: string; }
|
||||
>x : string
|
||||
>'abc' : "abc"
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
tests/cases/compiler/conflictMarkerDiff3Trivia1.ts(2,1): error TS1185: Merge conflict marker encountered.
|
||||
tests/cases/compiler/conflictMarkerDiff3Trivia1.ts(4,1): error TS1185: Merge conflict marker encountered.
|
||||
tests/cases/compiler/conflictMarkerDiff3Trivia1.ts(6,1): error TS1185: Merge conflict marker encountered.
|
||||
tests/cases/compiler/conflictMarkerDiff3Trivia1.ts(8,1): error TS1185: Merge conflict marker encountered.
|
||||
|
||||
|
||||
==== tests/cases/compiler/conflictMarkerDiff3Trivia1.ts (4 errors) ====
|
||||
class C {
|
||||
<<<<<<< HEAD
|
||||
~~~~~~~
|
||||
!!! error TS1185: Merge conflict marker encountered.
|
||||
v = 1;
|
||||
||||||| merged common ancestors
|
||||
~~~~~~~
|
||||
!!! error TS1185: Merge conflict marker encountered.
|
||||
v = 3;
|
||||
=======
|
||||
~~~~~~~
|
||||
!!! error TS1185: Merge conflict marker encountered.
|
||||
v = 2;
|
||||
>>>>>>> Branch-a
|
||||
~~~~~~~
|
||||
!!! error TS1185: Merge conflict marker encountered.
|
||||
}
|
18
tests/baselines/reference/conflictMarkerDiff3Trivia1.js
Normal file
18
tests/baselines/reference/conflictMarkerDiff3Trivia1.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
//// [conflictMarkerDiff3Trivia1.ts]
|
||||
class C {
|
||||
<<<<<<< HEAD
|
||||
v = 1;
|
||||
||||||| merged common ancestors
|
||||
v = 3;
|
||||
=======
|
||||
v = 2;
|
||||
>>>>>>> Branch-a
|
||||
}
|
||||
|
||||
//// [conflictMarkerDiff3Trivia1.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
this.v = 1;
|
||||
}
|
||||
return C;
|
||||
}());
|
|
@ -0,0 +1,34 @@
|
|||
tests/cases/compiler/conflictMarkerDiff3Trivia2.ts(3,1): error TS1185: Merge conflict marker encountered.
|
||||
tests/cases/compiler/conflictMarkerDiff3Trivia2.ts(4,6): error TS2304: Cannot find name 'a'.
|
||||
tests/cases/compiler/conflictMarkerDiff3Trivia2.ts(6,1): error TS1185: Merge conflict marker encountered.
|
||||
tests/cases/compiler/conflictMarkerDiff3Trivia2.ts(9,1): error TS1185: Merge conflict marker encountered.
|
||||
tests/cases/compiler/conflictMarkerDiff3Trivia2.ts(12,1): error TS1185: Merge conflict marker encountered.
|
||||
|
||||
|
||||
==== tests/cases/compiler/conflictMarkerDiff3Trivia2.ts (5 errors) ====
|
||||
class C {
|
||||
foo() {
|
||||
<<<<<<< B
|
||||
~~~~~~~
|
||||
!!! error TS1185: Merge conflict marker encountered.
|
||||
a();
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'a'.
|
||||
}
|
||||
||||||| merged common ancestors
|
||||
~~~~~~~
|
||||
!!! error TS1185: Merge conflict marker encountered.
|
||||
c();
|
||||
}
|
||||
=======
|
||||
~~~~~~~
|
||||
!!! error TS1185: Merge conflict marker encountered.
|
||||
b();
|
||||
}
|
||||
>>>>>>> A
|
||||
~~~~~~~
|
||||
!!! error TS1185: Merge conflict marker encountered.
|
||||
|
||||
public bar() { }
|
||||
}
|
||||
|
28
tests/baselines/reference/conflictMarkerDiff3Trivia2.js
Normal file
28
tests/baselines/reference/conflictMarkerDiff3Trivia2.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
//// [conflictMarkerDiff3Trivia2.ts]
|
||||
class C {
|
||||
foo() {
|
||||
<<<<<<< B
|
||||
a();
|
||||
}
|
||||
||||||| merged common ancestors
|
||||
c();
|
||||
}
|
||||
=======
|
||||
b();
|
||||
}
|
||||
>>>>>>> A
|
||||
|
||||
public bar() { }
|
||||
}
|
||||
|
||||
|
||||
//// [conflictMarkerDiff3Trivia2.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
a();
|
||||
};
|
||||
C.prototype.bar = function () { };
|
||||
return C;
|
||||
}());
|
9
tests/cases/compiler/conflictMarkerDiff3Trivia1.ts
Normal file
9
tests/cases/compiler/conflictMarkerDiff3Trivia1.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
class C {
|
||||
<<<<<<< HEAD
|
||||
v = 1;
|
||||
||||||| merged common ancestors
|
||||
v = 3;
|
||||
=======
|
||||
v = 2;
|
||||
>>>>>>> Branch-a
|
||||
}
|
15
tests/cases/compiler/conflictMarkerDiff3Trivia2.ts
Normal file
15
tests/cases/compiler/conflictMarkerDiff3Trivia2.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
class C {
|
||||
foo() {
|
||||
<<<<<<< B
|
||||
a();
|
||||
}
|
||||
||||||| merged common ancestors
|
||||
c();
|
||||
}
|
||||
=======
|
||||
b();
|
||||
}
|
||||
>>>>>>> A
|
||||
|
||||
public bar() { }
|
||||
}
|
|
@ -18,6 +18,19 @@ function foo(opts) {
|
|||
|
||||
foo({x: 'abc'});
|
||||
|
||||
/**
|
||||
* @typedef {Object} AnotherOpts
|
||||
* @property anotherX {string}
|
||||
* @property anotherY {string=}
|
||||
*
|
||||
* @param {AnotherOpts} opts
|
||||
*/
|
||||
function foo1(opts) {
|
||||
opts.anotherX;
|
||||
}
|
||||
|
||||
foo1({anotherX: "world"});
|
||||
|
||||
/**
|
||||
* @typedef {object} Opts1
|
||||
* @property {string} x
|
||||
|
@ -27,7 +40,7 @@ foo({x: 'abc'});
|
|||
*
|
||||
* @param {Opts1} opts
|
||||
*/
|
||||
function foo1(opts) {
|
||||
function foo2(opts) {
|
||||
opts.x;
|
||||
}
|
||||
foo1({x: 'abc'});
|
||||
foo2({x: 'abc'});
|
||||
|
|
22
tests/cases/fourslash/formatConflictDiff3Marker1.ts
Normal file
22
tests/cases/fourslash/formatConflictDiff3Marker1.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////class C {
|
||||
////<<<<<<< HEAD
|
||||
////v = 1;
|
||||
////||||||| merged common ancestors
|
||||
////v = 3;
|
||||
////=======
|
||||
////v = 2;
|
||||
////>>>>>>> Branch - a
|
||||
////}
|
||||
|
||||
format.document();
|
||||
verify.currentFileContentIs("class C {\r\n\
|
||||
<<<<<<< HEAD\r\n\
|
||||
v = 1;\r\n\
|
||||
||||||| merged common ancestors\r\n\
|
||||
v = 3;\r\n\
|
||||
=======\r\n\
|
||||
v = 2;\r\n\
|
||||
>>>>>>> Branch - a\r\n\
|
||||
}");
|
|
@ -0,0 +1,23 @@
|
|||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////class C {
|
||||
////<<<<<<< HEAD
|
||||
//// v = 1;
|
||||
////||||||| merged common ancestors
|
||||
//// v = 3;
|
||||
////=======
|
||||
//// v = 2;
|
||||
////>>>>>>> Branch - a
|
||||
////}
|
||||
|
||||
const c = classification;
|
||||
verify.syntacticClassificationsAre(
|
||||
c.keyword("class"), c.className("C"), c.punctuation("{"),
|
||||
c.comment("<<<<<<< HEAD"),
|
||||
c.identifier("v"), c.operator("="), c.numericLiteral("1"), c.punctuation(";"),
|
||||
c.comment("||||||| merged common ancestors"),
|
||||
c.identifier("v"), c.punctuation("="), c.numericLiteral("3"), c.punctuation(";"),
|
||||
c.comment("======="),
|
||||
c.identifier("v"), c.punctuation("="), c.numericLiteral("2"), c.punctuation(";"),
|
||||
c.comment(">>>>>>> Branch - a"),
|
||||
c.punctuation("}"));
|
|
@ -0,0 +1,19 @@
|
|||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////<<<<<<< HEAD
|
||||
////class C { }
|
||||
////||||||| merged common ancestors
|
||||
////class E { }
|
||||
////=======
|
||||
////class D { }
|
||||
////>>>>>>> Branch - a
|
||||
|
||||
const c = classification;
|
||||
verify.syntacticClassificationsAre(
|
||||
c.comment("<<<<<<< HEAD"),
|
||||
c.keyword("class"), c.className("C"), c.punctuation("{"), c.punctuation("}"),
|
||||
c.comment("||||||| merged common ancestors"),
|
||||
c.keyword("class"), c.identifier("E"), c.punctuation("{"), c.punctuation("}"),
|
||||
c.comment("======="),
|
||||
c.keyword("class"), c.identifier("D"), c.punctuation("{"), c.punctuation("}"),
|
||||
c.comment(">>>>>>> Branch - a"));
|
Loading…
Reference in a new issue