diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 2d0a4b66a1a..342414da843 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -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 = createNode(SyntaxKind.JSDocParameterTag, atToken.pos); + const result = shouldParseParamTag ? + createNode(SyntaxKind.JSDocParameterTag, atToken.pos) : + 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 = 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 = >[]; diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index d27bbf879fe..0a072a3b8ac 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -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; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 6f602ff23af..ebb0f02f39d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -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; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 134404c247b..506d2728ffd 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -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)) { diff --git a/src/harness/unittests/services/colorization.ts b/src/harness/unittests/services/colorization.ts index fd7d932885a..3fed9ec6164 100644 --- a/src/harness/unittests/services/colorization.ts +++ b/src/harness/unittests/services/colorization.ts @@ -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 () { diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index 797962cba08..de23b2649a6 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -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(); -} \ No newline at end of file +} diff --git a/src/services/classifier.ts b/src/services/classifier.ts index acee8fe4b0e..beeddda434e 100644 --- a/src/services/classifier.ts +++ b/src/services/classifier.ts @@ -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))) { diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argSynonymForParamTag.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argSynonymForParamTag.json index 064a040c58f..92b9cb450e6 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argSynonymForParamTag.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argSynonymForParamTag.json @@ -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 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argumentSynonymForParamTag.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argumentSynonymForParamTag.json index 264b5850223..f398fb3af41 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argumentSynonymForParamTag.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argumentSynonymForParamTag.json @@ -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 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.oneParamTag.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.oneParamTag.json index 9d303955ab1..e70fc95367f 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.oneParamTag.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.oneParamTag.json @@ -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 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTag1.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTag1.json index 1b87d268b93..0dbdd83d2ba 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTag1.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTag1.json @@ -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 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName1.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName1.json index fe01df58851..1df54fadcd7 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName1.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName1.json @@ -34,7 +34,7 @@ "end": 30, "text": "name1" }, - "parameterName": { + "name": { "kind": "Identifier", "pos": 25, "end": 30, diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName2.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName2.json index f50ce732606..5347b99be7a 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName2.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagBracketedName2.json @@ -34,7 +34,7 @@ "end": 31, "text": "name1" }, - "parameterName": { + "name": { "kind": "Identifier", "pos": 26, "end": 31, diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType1.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType1.json index 70f2641fd51..204d94779b3 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType1.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType1.json @@ -34,7 +34,7 @@ "end": 28 } }, - "parameterName": { + "name": { "kind": "Identifier", "pos": 15, "end": 20, diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType2.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType2.json index 4b720567cc7..7c79459768b 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType2.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramTagNameThenType2.json @@ -34,7 +34,7 @@ "end": 28 } }, - "parameterName": { + "name": { "kind": "Identifier", "pos": 15, "end": 20, diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramWithoutType.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramWithoutType.json index d77e80c7512..2ff182483d9 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramWithoutType.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.paramWithoutType.json @@ -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 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTag2.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTag2.json index 16968061afc..b51ab3598e6 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTag2.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTag2.json @@ -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 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTagOnSameLine.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTagOnSameLine.json index 8818c3a909e..3c20d5edcbc 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTagOnSameLine.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.twoParamTagOnSameLine.json @@ -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 } } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json index 7ef64f5a971..7a8f9c4bcc9 100644 --- a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.typedefTagWithChildrenTags.json @@ -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" } } ] diff --git a/tests/baselines/reference/checkJsdocTypedefInParamTag1.js b/tests/baselines/reference/checkJsdocTypedefInParamTag1.js index cc2e302ffca..d50f126c54e 100644 --- a/tests/baselines/reference/checkJsdocTypedefInParamTag1.js +++ b/tests/baselines/reference/checkJsdocTypedefInParamTag1.js @@ -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' }); diff --git a/tests/baselines/reference/checkJsdocTypedefInParamTag1.symbols b/tests/baselines/reference/checkJsdocTypedefInParamTag1.symbols index 844c4c045aa..e6f98a76fa3 100644 --- a/tests/baselines/reference/checkJsdocTypedefInParamTag1.symbols +++ b/tests/baselines/reference/checkJsdocTypedefInParamTag1.symbols @@ -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)) diff --git a/tests/baselines/reference/checkJsdocTypedefInParamTag1.types b/tests/baselines/reference/checkJsdocTypedefInParamTag1.types index cb21ea2ef06..b0847a71522 100644 --- a/tests/baselines/reference/checkJsdocTypedefInParamTag1.types +++ b/tests/baselines/reference/checkJsdocTypedefInParamTag1.types @@ -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" diff --git a/tests/baselines/reference/conflictMarkerDiff3Trivia1.errors.txt b/tests/baselines/reference/conflictMarkerDiff3Trivia1.errors.txt new file mode 100644 index 00000000000..b38e4e189ee --- /dev/null +++ b/tests/baselines/reference/conflictMarkerDiff3Trivia1.errors.txt @@ -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. + } \ No newline at end of file diff --git a/tests/baselines/reference/conflictMarkerDiff3Trivia1.js b/tests/baselines/reference/conflictMarkerDiff3Trivia1.js new file mode 100644 index 00000000000..86cccd44e18 --- /dev/null +++ b/tests/baselines/reference/conflictMarkerDiff3Trivia1.js @@ -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; +}()); diff --git a/tests/baselines/reference/conflictMarkerDiff3Trivia2.errors.txt b/tests/baselines/reference/conflictMarkerDiff3Trivia2.errors.txt new file mode 100644 index 00000000000..2e29826c43a --- /dev/null +++ b/tests/baselines/reference/conflictMarkerDiff3Trivia2.errors.txt @@ -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() { } + } + \ No newline at end of file diff --git a/tests/baselines/reference/conflictMarkerDiff3Trivia2.js b/tests/baselines/reference/conflictMarkerDiff3Trivia2.js new file mode 100644 index 00000000000..61a2273019b --- /dev/null +++ b/tests/baselines/reference/conflictMarkerDiff3Trivia2.js @@ -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; +}()); diff --git a/tests/cases/compiler/conflictMarkerDiff3Trivia1.ts b/tests/cases/compiler/conflictMarkerDiff3Trivia1.ts new file mode 100644 index 00000000000..072cc4b9683 --- /dev/null +++ b/tests/cases/compiler/conflictMarkerDiff3Trivia1.ts @@ -0,0 +1,9 @@ +class C { +<<<<<<< HEAD + v = 1; +||||||| merged common ancestors + v = 3; +======= + v = 2; +>>>>>>> Branch-a +} \ No newline at end of file diff --git a/tests/cases/compiler/conflictMarkerDiff3Trivia2.ts b/tests/cases/compiler/conflictMarkerDiff3Trivia2.ts new file mode 100644 index 00000000000..023d425cd4d --- /dev/null +++ b/tests/cases/compiler/conflictMarkerDiff3Trivia2.ts @@ -0,0 +1,15 @@ +class C { + foo() { +<<<<<<< B + a(); + } +||||||| merged common ancestors + c(); + } +======= + b(); + } +>>>>>>> A + + public bar() { } +} diff --git a/tests/cases/conformance/jsdoc/checkJsdocTypedefInParamTag1.ts b/tests/cases/conformance/jsdoc/checkJsdocTypedefInParamTag1.ts index fa885b9f316..89f609be202 100644 --- a/tests/cases/conformance/jsdoc/checkJsdocTypedefInParamTag1.ts +++ b/tests/cases/conformance/jsdoc/checkJsdocTypedefInParamTag1.ts @@ -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'}); diff --git a/tests/cases/fourslash/formatConflictDiff3Marker1.ts b/tests/cases/fourslash/formatConflictDiff3Marker1.ts new file mode 100644 index 00000000000..f6492a6f60c --- /dev/null +++ b/tests/cases/fourslash/formatConflictDiff3Marker1.ts @@ -0,0 +1,22 @@ +/// + +////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\ +}"); \ No newline at end of file diff --git a/tests/cases/fourslash/syntacticClassificationsConflictDiff3Markers1.ts b/tests/cases/fourslash/syntacticClassificationsConflictDiff3Markers1.ts new file mode 100644 index 00000000000..669705307a9 --- /dev/null +++ b/tests/cases/fourslash/syntacticClassificationsConflictDiff3Markers1.ts @@ -0,0 +1,23 @@ +/// + +////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("}")); \ No newline at end of file diff --git a/tests/cases/fourslash/syntacticClassificationsConflictDiff3Markers2.ts b/tests/cases/fourslash/syntacticClassificationsConflictDiff3Markers2.ts new file mode 100644 index 00000000000..17144397184 --- /dev/null +++ b/tests/cases/fourslash/syntacticClassificationsConflictDiff3Markers2.ts @@ -0,0 +1,19 @@ +/// + +////<<<<<<< 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")); \ No newline at end of file