* Probably fix 18224

* Corrected test
This commit is contained in:
Wesley Wigham 2017-09-06 14:44:29 -07:00 committed by GitHub
parent 36607e1bde
commit 73eff819b5
5 changed files with 31 additions and 1 deletions

View file

@ -18017,7 +18017,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);