parent
36607e1bde
commit
73eff819b5
|
@ -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;
|
||||
|
|
8
tests/baselines/reference/jsdocTypecastNoTypeNoCrash.js
Normal file
8
tests/baselines/reference/jsdocTypecastNoTypeNoCrash.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
//// [index.js]
|
||||
function Foo() {}
|
||||
const a = /* @type string */(Foo);
|
||||
|
||||
|
||||
//// [index.js]
|
||||
function Foo() { }
|
||||
var a = (Foo);
|
|
@ -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))
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
=== tests/cases/compiler/index.js ===
|
||||
function Foo() {}
|
||||
>Foo : () => void
|
||||
|
||||
const a = /* @type string */(Foo);
|
||||
>a : () => void
|
||||
>(Foo) : () => void
|
||||
>Foo : () => void
|
||||
|
5
tests/cases/compiler/jsdocTypecastNoTypeNoCrash.ts
Normal file
5
tests/cases/compiler/jsdocTypecastNoTypeNoCrash.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
// @allowJS: true
|
||||
// @outDir: ./out
|
||||
// @filename: index.js
|
||||
function Foo() {}
|
||||
const a = /* @type string */(Foo);
|
Loading…
Reference in a new issue