* Probably fix 18224

* Corrected test
This commit is contained in:
Wesley Wigham
2017-09-06 22:09:38 -07:00
committed by GitHub
parent 0ff8eeb308
commit 16a4997565
5 changed files with 31 additions and 1 deletions

View File

@@ -18034,7 +18034,7 @@ namespace ts {
function checkParenthesizedExpression(node: ParenthesizedExpression, checkMode?: CheckMode): Type {
if (isInJavaScriptFile(node) && node.jsDoc) {
const typecasts = flatMap(node.jsDoc, doc => filter(doc.tags, tag => tag.kind === SyntaxKind.JSDocTypeTag));
const typecasts = flatMap(node.jsDoc, doc => filter(doc.tags, tag => tag.kind === SyntaxKind.JSDocTypeTag && !!(tag as JSDocTypeTag).typeExpression && !!(tag as JSDocTypeTag).typeExpression.type));
if (typecasts && typecasts.length) {
// We should have already issued an error if there were multiple type jsdocs
const cast = typecasts[0] as JSDocTypeTag;

View File

@@ -0,0 +1,8 @@
//// [index.js]
function Foo() {}
const a = /* @type string */(Foo);
//// [index.js]
function Foo() { }
var a = (Foo);

View File

@@ -0,0 +1,8 @@
=== tests/cases/compiler/index.js ===
function Foo() {}
>Foo : Symbol(Foo, Decl(index.js, 0, 0))
const a = /* @type string */(Foo);
>a : Symbol(a, Decl(index.js, 1, 5))
>Foo : Symbol(Foo, Decl(index.js, 0, 0))

View File

@@ -0,0 +1,9 @@
=== tests/cases/compiler/index.js ===
function Foo() {}
>Foo : () => void
const a = /* @type string */(Foo);
>a : () => void
>(Foo) : () => void
>Foo : () => void

View File

@@ -0,0 +1,5 @@
// @allowJS: true
// @outDir: ./out
// @filename: index.js
function Foo() {}
const a = /* @type string */(Foo);