Skip to content

Commit d5538f0

Browse files
committed
Merge pull request #7036 from RyanCavanaugh/port7007
Port PR 7007 to release 1.8
2 parents 1173473 + 6658e21 commit d5538f0

File tree

6 files changed

+58
-4
lines changed

6 files changed

+58
-4
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2621,7 +2621,7 @@ namespace ts {
26212621
function getJSDocTypeForVariableLikeDeclarationFromJSDocComment(declaration: VariableLikeDeclaration): JSDocType {
26222622
// First, see if this node has an @type annotation on it directly.
26232623
const typeTag = getJSDocTypeTag(declaration);
2624-
if (typeTag) {
2624+
if (typeTag && typeTag.typeExpression) {
26252625
return typeTag.typeExpression.type;
26262626
}
26272627

@@ -2631,7 +2631,7 @@ namespace ts {
26312631

26322632
// @type annotation might have been on the variable statement, try that instead.
26332633
const annotation = getJSDocTypeTag(declaration.parent.parent);
2634-
if (annotation) {
2634+
if (annotation && annotation.typeExpression) {
26352635
return annotation.typeExpression.type;
26362636
}
26372637
}
@@ -7447,7 +7447,7 @@ namespace ts {
74477447

74487448
function getTypeForThisExpressionFromJSDoc(node: Node) {
74497449
const typeTag = getJSDocTypeTag(node);
7450-
if (typeTag && typeTag.typeExpression.type.kind === SyntaxKind.JSDocFunctionType) {
7450+
if (typeTag && typeTag.typeExpression && typeTag.typeExpression.type && typeTag.typeExpression.type.kind === SyntaxKind.JSDocFunctionType) {
74517451
const jsDocFunctionType = <JSDocFunctionType>typeTag.typeExpression.type;
74527452
if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === SyntaxKind.JSDocThisType) {
74537453
return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type);

src/harness/harness.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,8 @@ namespace Harness {
904904
{ name: "includeBuiltFile", type: "string" },
905905
{ name: "fileName", type: "string" },
906906
{ name: "libFiles", type: "string" },
907-
{ name: "noErrorTruncation", type: "boolean" }
907+
{ name: "noErrorTruncation", type: "boolean" },
908+
{ name: "suppressOutputPathCheck", type: "boolean" }
908909
];
909910

910911
let optionsIndex: ts.Map<ts.CommandLineOption>;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//// [myFile02.js]
2+
3+
/**
4+
* Checks if `value` is classified as an `Array` object.
5+
*
6+
* @type Function
7+
*/
8+
var isArray = Array.isArray;
9+
10+
11+
//// [myFile02.js]
12+
/**
13+
* Checks if `value` is classified as an `Array` object.
14+
*
15+
* @type Function
16+
*/
17+
var isArray = Array.isArray;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
=== tests/cases/conformance/salsa/myFile02.js ===
2+
3+
/**
4+
* Checks if `value` is classified as an `Array` object.
5+
*
6+
* @type Function
7+
*/
8+
var isArray = Array.isArray;
9+
>isArray : Symbol(isArray, Decl(myFile02.js, 6, 3))
10+
>Array.isArray : Symbol(ArrayConstructor.isArray, Decl(lib.d.ts, --, --))
11+
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
12+
>isArray : Symbol(ArrayConstructor.isArray, Decl(lib.d.ts, --, --))
13+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
=== tests/cases/conformance/salsa/myFile02.js ===
2+
3+
/**
4+
* Checks if `value` is classified as an `Array` object.
5+
*
6+
* @type Function
7+
*/
8+
var isArray = Array.isArray;
9+
>isArray : (arg: any) => arg is any[]
10+
>Array.isArray : (arg: any) => arg is any[]
11+
>Array : ArrayConstructor
12+
>isArray : (arg: any) => arg is any[]
13+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// @allowJS: true
2+
// @suppressOutputPathCheck: true
3+
4+
// @filename: myFile02.js
5+
/**
6+
* Checks if `value` is classified as an `Array` object.
7+
*
8+
* @type Function
9+
*/
10+
var isArray = Array.isArray;

0 commit comments

Comments
 (0)