Skip to content
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: 6 additions & 0 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30833,6 +30833,10 @@ namespace ts {
}
}

function checkJSDocPropertyTag(node: JSDocPropertyTag) {
checkSourceElement(node.typeExpression);
}

function checkJSDocFunctionType(node: JSDocFunctionType): void {
if (produceDiagnostics && !node.type && !isJSDocConstructSignature(node)) {
reportImplicitAny(node, anyType);
Expand Down Expand Up @@ -34362,6 +34366,8 @@ namespace ts {
return checkJSDocTypeTag(node as JSDocTypeTag);
case SyntaxKind.JSDocParameterTag:
return checkJSDocParameterTag(node as JSDocParameterTag);
case SyntaxKind.JSDocPropertyTag:
return checkJSDocPropertyTag(node as JSDocPropertyTag);
case SyntaxKind.JSDocFunctionType:
checkJSDocFunctionType(node as JSDocFunctionType);
// falls through
Expand Down
18 changes: 18 additions & 0 deletions tests/baselines/reference/jsdocPropertyTagInvalid.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/a.js(3,15): error TS2304: Cannot find name 'sting'.


==== /a.js (1 errors) ====
/**
* @typedef MyType
* @property {sting} [x]
~~~~~
!!! error TS2304: Cannot find name 'sting'.
*/

/** @param {MyType} p */
export function f(p) { }

==== /b.js (0 errors) ====
import { f } from "./a.js"
f({ x: 42 })

19 changes: 19 additions & 0 deletions tests/baselines/reference/jsdocPropertyTagInvalid.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
=== /a.js ===
/**
* @typedef MyType
* @property {sting} [x]
*/

/** @param {MyType} p */
export function f(p) { }
>f : Symbol(f, Decl(a.js, 0, 0))
>p : Symbol(p, Decl(a.js, 6, 18))

=== /b.js ===
import { f } from "./a.js"
>f : Symbol(f, Decl(b.js, 0, 8))

f({ x: 42 })
>f : Symbol(f, Decl(b.js, 0, 8))
>x : Symbol(x, Decl(b.js, 1, 3))

22 changes: 22 additions & 0 deletions tests/baselines/reference/jsdocPropertyTagInvalid.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
=== /a.js ===
/**
* @typedef MyType
* @property {sting} [x]
*/

/** @param {MyType} p */
export function f(p) { }
>f : (p: MyType) => void
>p : MyType

=== /b.js ===
import { f } from "./a.js"
>f : (p: import("/a").MyType) => void

f({ x: 42 })
>f({ x: 42 }) : void
>f : (p: import("/a").MyType) => void
>{ x: 42 } : { x: number; }
>x : number
>42 : 42

16 changes: 16 additions & 0 deletions tests/cases/compiler/jsdocPropertyTagInvalid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// @allowJs: true
// @checkJs: true
// @noEmit: true

// @Filename: /a.js
/**
* @typedef MyType
* @property {sting} [x]
*/

/** @param {MyType} p */
export function f(p) { }

// @Filename: /b.js
import { f } from "./a.js"
f({ x: 42 })