mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-27 04:46:25 -05:00
Merge pull request #16134 from Microsoft/master-fix15250
[Master] Fix 15250 - treat "object" and "Object" the same in JSDoc type def
This commit is contained in:
@@ -6094,7 +6094,6 @@ namespace ts {
|
||||
case SyntaxKind.NullKeyword:
|
||||
case SyntaxKind.UndefinedKeyword:
|
||||
case SyntaxKind.NeverKeyword:
|
||||
case SyntaxKind.ObjectKeyword:
|
||||
return parseTokenNode<JSDocType>();
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
@@ -6772,7 +6771,7 @@ namespace ts {
|
||||
const jsDocTypeReference = <JSDocTypeReference>typeExpression.type;
|
||||
if (jsDocTypeReference.name.kind === SyntaxKind.Identifier) {
|
||||
const name = <Identifier>jsDocTypeReference.name;
|
||||
if (name.text === "Object") {
|
||||
if (name.text === "Object" || name.text === "object") {
|
||||
typedefTag.jsDocTypeLiteral = scanChildTags();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,29 @@
|
||||
* @property {string=} y
|
||||
* @property {string} [z]
|
||||
* @property {string} [w="hi"]
|
||||
*
|
||||
*
|
||||
* @param {Opts} opts
|
||||
*/
|
||||
function foo(opts) {}
|
||||
function foo(opts) {
|
||||
opts.x;
|
||||
}
|
||||
|
||||
foo({x: 'abc'});
|
||||
foo({x: 'abc'});
|
||||
|
||||
/**
|
||||
* @typedef {object} Opts1
|
||||
* @property {string} x
|
||||
* @property {string=} y
|
||||
* @property {string} [z]
|
||||
* @property {string} [w="hi"]
|
||||
*
|
||||
* @param {Opts1} opts
|
||||
*/
|
||||
function foo1(opts) {
|
||||
opts.x;
|
||||
}
|
||||
foo1({x: 'abc'});
|
||||
|
||||
|
||||
//// [0.js]
|
||||
// @ts-check
|
||||
@@ -24,5 +41,20 @@ foo({x: 'abc'});
|
||||
*
|
||||
* @param {Opts} opts
|
||||
*/
|
||||
function foo(opts) { }
|
||||
function foo(opts) {
|
||||
opts.x;
|
||||
}
|
||||
foo({ x: 'abc' });
|
||||
/**
|
||||
* @typedef {object} Opts1
|
||||
* @property {string} x
|
||||
* @property {string=} y
|
||||
* @property {string} [z]
|
||||
* @property {string} [w="hi"]
|
||||
*
|
||||
* @param {Opts1} opts
|
||||
*/
|
||||
function foo1(opts) {
|
||||
opts.x;
|
||||
}
|
||||
foo1({ x: 'abc' });
|
||||
|
||||
@@ -6,14 +6,42 @@
|
||||
* @property {string=} y
|
||||
* @property {string} [z]
|
||||
* @property {string} [w="hi"]
|
||||
*
|
||||
*
|
||||
* @param {Opts} opts
|
||||
*/
|
||||
function foo(opts) {}
|
||||
function foo(opts) {
|
||||
>foo : Symbol(foo, Decl(0.js, 0, 0))
|
||||
>opts : Symbol(opts, Decl(0.js, 10, 13))
|
||||
|
||||
opts.x;
|
||||
>opts.x : Symbol(x, Decl(0.js, 3, 3))
|
||||
>opts : Symbol(opts, Decl(0.js, 10, 13))
|
||||
>x : Symbol(x, Decl(0.js, 3, 3))
|
||||
}
|
||||
|
||||
foo({x: 'abc'});
|
||||
>foo : Symbol(foo, Decl(0.js, 0, 0))
|
||||
>x : Symbol(x, Decl(0.js, 12, 5))
|
||||
>x : Symbol(x, Decl(0.js, 14, 5))
|
||||
|
||||
/**
|
||||
* @typedef {object} Opts1
|
||||
* @property {string} x
|
||||
* @property {string=} y
|
||||
* @property {string} [z]
|
||||
* @property {string} [w="hi"]
|
||||
*
|
||||
* @param {Opts1} opts
|
||||
*/
|
||||
function foo1(opts) {
|
||||
>foo1 : Symbol(foo1, Decl(0.js, 14, 16))
|
||||
>opts : Symbol(opts, Decl(0.js, 25, 14))
|
||||
|
||||
opts.x;
|
||||
>opts.x : Symbol(x, Decl(0.js, 18, 3))
|
||||
>opts : Symbol(opts, Decl(0.js, 25, 14))
|
||||
>x : Symbol(x, Decl(0.js, 18, 3))
|
||||
}
|
||||
foo1({x: 'abc'});
|
||||
>foo1 : Symbol(foo1, Decl(0.js, 14, 16))
|
||||
>x : Symbol(x, Decl(0.js, 28, 6))
|
||||
|
||||
|
||||
@@ -6,13 +6,19 @@
|
||||
* @property {string=} y
|
||||
* @property {string} [z]
|
||||
* @property {string} [w="hi"]
|
||||
*
|
||||
*
|
||||
* @param {Opts} opts
|
||||
*/
|
||||
function foo(opts) {}
|
||||
function foo(opts) {
|
||||
>foo : (opts: { x: string; y?: string; z?: string; w?: string; }) => void
|
||||
>opts : { x: string; y?: string; z?: string; w?: string; }
|
||||
|
||||
opts.x;
|
||||
>opts.x : string
|
||||
>opts : { x: string; y?: string; z?: string; w?: string; }
|
||||
>x : string
|
||||
}
|
||||
|
||||
foo({x: 'abc'});
|
||||
>foo({x: 'abc'}) : void
|
||||
>foo : (opts: { x: string; y?: string; z?: string; w?: string; }) => void
|
||||
@@ -20,3 +26,28 @@ foo({x: 'abc'});
|
||||
>x : string
|
||||
>'abc' : "abc"
|
||||
|
||||
/**
|
||||
* @typedef {object} Opts1
|
||||
* @property {string} x
|
||||
* @property {string=} y
|
||||
* @property {string} [z]
|
||||
* @property {string} [w="hi"]
|
||||
*
|
||||
* @param {Opts1} opts
|
||||
*/
|
||||
function foo1(opts) {
|
||||
>foo1 : (opts: { x: string; y?: string; z?: string; w?: string; }) => void
|
||||
>opts : { x: string; y?: string; z?: string; w?: string; }
|
||||
|
||||
opts.x;
|
||||
>opts.x : string
|
||||
>opts : { x: string; y?: string; z?: string; w?: string; }
|
||||
>x : string
|
||||
}
|
||||
foo1({x: 'abc'});
|
||||
>foo1({x: 'abc'}) : void
|
||||
>foo1 : (opts: { x: string; y?: string; z?: string; w?: string; }) => void
|
||||
>{x: 'abc'} : { x: string; }
|
||||
>x : string
|
||||
>'abc' : "abc"
|
||||
|
||||
|
||||
234
tests/baselines/reference/jsDocTypedef1.js
Normal file
234
tests/baselines/reference/jsDocTypedef1.js
Normal file
@@ -0,0 +1,234 @@
|
||||
[
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypedef1.js",
|
||||
"position": 189
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "parameter",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 189,
|
||||
"length": 4
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "(",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "parameter",
|
||||
"kind": "text"
|
||||
},
|
||||
{
|
||||
"text": ")",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "opts",
|
||||
"kind": "parameterName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "{",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "\n",
|
||||
"kind": "lineBreak"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "x",
|
||||
"kind": "propertyName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "string",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": ";",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "\n",
|
||||
"kind": "lineBreak"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "y",
|
||||
"kind": "propertyName"
|
||||
},
|
||||
{
|
||||
"text": "?",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "string",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": ";",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "\n",
|
||||
"kind": "lineBreak"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "z",
|
||||
"kind": "propertyName"
|
||||
},
|
||||
{
|
||||
"text": "?",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "string",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": ";",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "\n",
|
||||
"kind": "lineBreak"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "w",
|
||||
"kind": "propertyName"
|
||||
},
|
||||
{
|
||||
"text": "?",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "string",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": ";",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "\n",
|
||||
"kind": "lineBreak"
|
||||
},
|
||||
{
|
||||
"text": "}",
|
||||
"kind": "punctuation"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypedef1.js",
|
||||
"position": 424
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "parameter",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 424,
|
||||
"length": 5
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "(",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "parameter",
|
||||
"kind": "text"
|
||||
},
|
||||
{
|
||||
"text": ")",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "opts1",
|
||||
"kind": "parameterName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "any",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -9,9 +9,25 @@
|
||||
* @property {string=} y
|
||||
* @property {string} [z]
|
||||
* @property {string} [w="hi"]
|
||||
*
|
||||
*
|
||||
* @param {Opts} opts
|
||||
*/
|
||||
function foo(opts) {}
|
||||
function foo(opts) {
|
||||
opts.x;
|
||||
}
|
||||
|
||||
foo({x: 'abc'});
|
||||
foo({x: 'abc'});
|
||||
|
||||
/**
|
||||
* @typedef {object} Opts1
|
||||
* @property {string} x
|
||||
* @property {string=} y
|
||||
* @property {string} [z]
|
||||
* @property {string} [w="hi"]
|
||||
*
|
||||
* @param {Opts1} opts
|
||||
*/
|
||||
function foo1(opts) {
|
||||
opts.x;
|
||||
}
|
||||
foo1({x: 'abc'});
|
||||
|
||||
33
tests/cases/fourslash/jsDocTypedefQuickInfo1.ts
Normal file
33
tests/cases/fourslash/jsDocTypedefQuickInfo1.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
// @allowJs: true
|
||||
// @Filename: jsDocTypedef1.js
|
||||
//// /**
|
||||
//// * @typedef {Object} Opts
|
||||
//// * @property {string} x
|
||||
//// * @property {string=} y
|
||||
//// * @property {string} [z]
|
||||
//// * @property {string} [w="hi"]
|
||||
//// *
|
||||
//// * @param {Opts} opts
|
||||
//// */
|
||||
//// function foo(/*1*/opts) {
|
||||
//// opts.x;
|
||||
///// }
|
||||
|
||||
//// foo({x: 'abc'});
|
||||
|
||||
//// /**
|
||||
//// * @typedef {object} Opts1
|
||||
//// * @property {string} x
|
||||
//// * @property {string=} y
|
||||
//// * @property {string} [z]
|
||||
//// * @property {string} [w="hi"]
|
||||
//// *
|
||||
//// * @param {Opts1} opts
|
||||
//// */
|
||||
//// function foo1(/*2*/opts1) {
|
||||
//// opts1.x;
|
||||
//// }
|
||||
//// foo1({x: 'abc'});
|
||||
|
||||
verify.baselineQuickInfo();
|
||||
Reference in New Issue
Block a user