Skip to content

Commit 11043b0

Browse files
authored
Check JSDocPropetyTag (microsoft#37544)
Fixes microsoft#37040
1 parent 38e717a commit 11043b0

File tree

5 files changed

+81
-0
lines changed

5 files changed

+81
-0
lines changed

src/compiler/checker.ts

+6
Original file line numberDiff line numberDiff line change
@@ -30833,6 +30833,10 @@ namespace ts {
3083330833
}
3083430834
}
3083530835

30836+
function checkJSDocPropertyTag(node: JSDocPropertyTag) {
30837+
checkSourceElement(node.typeExpression);
30838+
}
30839+
3083630840
function checkJSDocFunctionType(node: JSDocFunctionType): void {
3083730841
if (produceDiagnostics && !node.type && !isJSDocConstructSignature(node)) {
3083830842
reportImplicitAny(node, anyType);
@@ -34362,6 +34366,8 @@ namespace ts {
3436234366
return checkJSDocTypeTag(node as JSDocTypeTag);
3436334367
case SyntaxKind.JSDocParameterTag:
3436434368
return checkJSDocParameterTag(node as JSDocParameterTag);
34369+
case SyntaxKind.JSDocPropertyTag:
34370+
return checkJSDocPropertyTag(node as JSDocPropertyTag);
3436534371
case SyntaxKind.JSDocFunctionType:
3436634372
checkJSDocFunctionType(node as JSDocFunctionType);
3436734373
// falls through
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/a.js(3,15): error TS2304: Cannot find name 'sting'.
2+
3+
4+
==== /a.js (1 errors) ====
5+
/**
6+
* @typedef MyType
7+
* @property {sting} [x]
8+
~~~~~
9+
!!! error TS2304: Cannot find name 'sting'.
10+
*/
11+
12+
/** @param {MyType} p */
13+
export function f(p) { }
14+
15+
==== /b.js (0 errors) ====
16+
import { f } from "./a.js"
17+
f({ x: 42 })
18+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
=== /a.js ===
2+
/**
3+
* @typedef MyType
4+
* @property {sting} [x]
5+
*/
6+
7+
/** @param {MyType} p */
8+
export function f(p) { }
9+
>f : Symbol(f, Decl(a.js, 0, 0))
10+
>p : Symbol(p, Decl(a.js, 6, 18))
11+
12+
=== /b.js ===
13+
import { f } from "./a.js"
14+
>f : Symbol(f, Decl(b.js, 0, 8))
15+
16+
f({ x: 42 })
17+
>f : Symbol(f, Decl(b.js, 0, 8))
18+
>x : Symbol(x, Decl(b.js, 1, 3))
19+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
=== /a.js ===
2+
/**
3+
* @typedef MyType
4+
* @property {sting} [x]
5+
*/
6+
7+
/** @param {MyType} p */
8+
export function f(p) { }
9+
>f : (p: MyType) => void
10+
>p : MyType
11+
12+
=== /b.js ===
13+
import { f } from "./a.js"
14+
>f : (p: import("/a").MyType) => void
15+
16+
f({ x: 42 })
17+
>f({ x: 42 }) : void
18+
>f : (p: import("/a").MyType) => void
19+
>{ x: 42 } : { x: number; }
20+
>x : number
21+
>42 : 42
22+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// @allowJs: true
2+
// @checkJs: true
3+
// @noEmit: true
4+
5+
// @Filename: /a.js
6+
/**
7+
* @typedef MyType
8+
* @property {sting} [x]
9+
*/
10+
11+
/** @param {MyType} p */
12+
export function f(p) { }
13+
14+
// @Filename: /b.js
15+
import { f } from "./a.js"
16+
f({ x: 42 })

0 commit comments

Comments
 (0)