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
7 changes: 5 additions & 2 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2178,7 +2178,10 @@ namespace ts {
case SyntaxKind.JSDocRecordMember:
return bindPropertyWorker(node as JSDocRecordMember);
case SyntaxKind.JSDocPropertyTag:
return declareSymbolAndAddToSymbolTable(node as JSDocPropertyTag, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
return declareSymbolAndAddToSymbolTable(node as JSDocPropertyTag,
(node as JSDocPropertyTag).typeExpression && (node as JSDocPropertyTag).typeExpression.type.kind === SyntaxKind.JSDocOptionalType ?
SymbolFlags.Property | SymbolFlags.Optional : SymbolFlags.Property,
SymbolFlags.PropertyExcludes);
case SyntaxKind.JSDocFunctionType:
return bindFunctionOrConstructorType(<SignatureDeclaration>node);
case SyntaxKind.JSDocTypeLiteral:
Expand Down Expand Up @@ -3593,4 +3596,4 @@ namespace ts {
return TransformFlags.NodeExcludes;
}
}
}
}
24 changes: 24 additions & 0 deletions tests/baselines/reference/checkJsdocTypedefInParamTag1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//// [0.js]
// @ts-check
/**
* @typedef {Object} Opts
* @property {string} x
* @property {string=} y
*
* @param {Opts} opts
*/
function foo(opts) {}

foo({x: 'abc'});

//// [0.js]
// @ts-check
/**
* @typedef {Object} Opts
* @property {string} x
* @property {string=} y
*
* @param {Opts} opts
*/
function foo(opts) { }
foo({ x: 'abc' });
17 changes: 17 additions & 0 deletions tests/baselines/reference/checkJsdocTypedefInParamTag1.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
=== tests/cases/conformance/jsdoc/0.js ===
// @ts-check
/**
* @typedef {Object} Opts
* @property {string} x
* @property {string=} y
*
* @param {Opts} opts
*/
function foo(opts) {}
>foo : Symbol(foo, Decl(0.js, 0, 0))
>opts : Symbol(opts, Decl(0.js, 8, 13))

foo({x: 'abc'});
>foo : Symbol(foo, Decl(0.js, 0, 0))
>x : Symbol(x, Decl(0.js, 10, 5))

20 changes: 20 additions & 0 deletions tests/baselines/reference/checkJsdocTypedefInParamTag1.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
=== tests/cases/conformance/jsdoc/0.js ===
// @ts-check
/**
* @typedef {Object} Opts
* @property {string} x
* @property {string=} y
*
* @param {Opts} opts
*/
function foo(opts) {}
>foo : (opts: { x: string; y?: string; }) => void
>opts : { x: string; y?: string; }

foo({x: 'abc'});
>foo({x: 'abc'}) : void
>foo : (opts: { x: string; y?: string; }) => void
>{x: 'abc'} : { x: string; }
>x : string
>'abc' : "abc"

15 changes: 15 additions & 0 deletions tests/cases/conformance/jsdoc/checkJsdocTypedefInParamTag1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// @allowJS: true
// @suppressOutputPathCheck: true

// @filename: 0.js
// @ts-check
/**
* @typedef {Object} Opts
* @property {string} x
* @property {string=} y
*
* @param {Opts} opts
*/
function foo(opts) {}

foo({x: 'abc'});