mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 01:33:15 -05:00
Merge pull request #16070 from Microsoft/master-15916
[Master] Take into account optional property in parameter
This commit is contained in:
@@ -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:
|
||||
@@ -3593,4 +3596,4 @@ namespace ts {
|
||||
return TransformFlags.NodeExcludes;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
24
tests/baselines/reference/checkJsdocTypedefInParamTag1.js
Normal file
24
tests/baselines/reference/checkJsdocTypedefInParamTag1.js
Normal file
@@ -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' });
|
||||
@@ -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
tests/baselines/reference/checkJsdocTypedefInParamTag1.types
Normal file
20
tests/baselines/reference/checkJsdocTypedefInParamTag1.types
Normal file
@@ -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"
|
||||
|
||||
@@ -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'});
|
||||
Reference in New Issue
Block a user