Skip to content

Port PR 7007 to release 1.8 #7036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2621,7 +2621,7 @@ namespace ts {
function getJSDocTypeForVariableLikeDeclarationFromJSDocComment(declaration: VariableLikeDeclaration): JSDocType {
// First, see if this node has an @type annotation on it directly.
const typeTag = getJSDocTypeTag(declaration);
if (typeTag) {
if (typeTag && typeTag.typeExpression) {
return typeTag.typeExpression.type;
}

Expand All @@ -2631,7 +2631,7 @@ namespace ts {

// @type annotation might have been on the variable statement, try that instead.
const annotation = getJSDocTypeTag(declaration.parent.parent);
if (annotation) {
if (annotation && annotation.typeExpression) {
return annotation.typeExpression.type;
}
}
Expand Down Expand Up @@ -7392,7 +7392,7 @@ namespace ts {

function getTypeForThisExpressionFromJSDoc(node: Node) {
const typeTag = getJSDocTypeTag(node);
if (typeTag && typeTag.typeExpression.type.kind === SyntaxKind.JSDocFunctionType) {
if (typeTag && typeTag.typeExpression && typeTag.typeExpression.type && typeTag.typeExpression.type.kind === SyntaxKind.JSDocFunctionType) {
const jsDocFunctionType = <JSDocFunctionType>typeTag.typeExpression.type;
if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === SyntaxKind.JSDocThisType) {
return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type);
Expand Down
3 changes: 2 additions & 1 deletion src/harness/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,8 @@ namespace Harness {
{ name: "includeBuiltFile", type: "string" },
{ name: "fileName", type: "string" },
{ name: "libFiles", type: "string" },
{ name: "noErrorTruncation", type: "boolean" }
{ name: "noErrorTruncation", type: "boolean" },
{ name: "suppressOutputPathCheck", type: "boolean" }
];

let optionsIndex: ts.Map<ts.CommandLineOption>;
Expand Down
17 changes: 17 additions & 0 deletions tests/baselines/reference/malformedTags.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//// [myFile02.js]

/**
* Checks if `value` is classified as an `Array` object.
*
* @type Function
*/
var isArray = Array.isArray;


//// [myFile02.js]
/**
* Checks if `value` is classified as an `Array` object.
*
* @type Function
*/
var isArray = Array.isArray;
13 changes: 13 additions & 0 deletions tests/baselines/reference/malformedTags.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
=== tests/cases/conformance/salsa/myFile02.js ===

/**
* Checks if `value` is classified as an `Array` object.
*
* @type Function
*/
var isArray = Array.isArray;
>isArray : Symbol(isArray, Decl(myFile02.js, 6, 3))
>Array.isArray : Symbol(ArrayConstructor.isArray, Decl(lib.d.ts, --, --))
>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>isArray : Symbol(ArrayConstructor.isArray, Decl(lib.d.ts, --, --))

13 changes: 13 additions & 0 deletions tests/baselines/reference/malformedTags.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
=== tests/cases/conformance/salsa/myFile02.js ===

/**
* Checks if `value` is classified as an `Array` object.
*
* @type Function
*/
var isArray = Array.isArray;
>isArray : (arg: any) => arg is any[]
>Array.isArray : (arg: any) => arg is any[]
>Array : ArrayConstructor
>isArray : (arg: any) => arg is any[]

10 changes: 10 additions & 0 deletions tests/cases/conformance/salsa/malformedTags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// @allowJS: true
// @suppressOutputPathCheck: true

// @filename: myFile02.js
/**
* Checks if `value` is classified as an `Array` object.
*
* @type Function
*/
var isArray = Array.isArray;