mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-12 20:25:48 -06:00
Merge branch 'master' into master-fix16092
This commit is contained in:
commit
27078f995e
@ -6855,6 +6855,7 @@ namespace ts {
|
||||
case "Object":
|
||||
return anyType;
|
||||
case "Function":
|
||||
case "function":
|
||||
return globalFunctionType;
|
||||
case "Array":
|
||||
case "array":
|
||||
|
||||
@ -6075,7 +6075,10 @@ namespace ts {
|
||||
case SyntaxKind.OpenBraceToken:
|
||||
return parseJSDocRecordType();
|
||||
case SyntaxKind.FunctionKeyword:
|
||||
return parseJSDocFunctionType();
|
||||
if (lookAhead(nextTokenIsOpenParen)) {
|
||||
return parseJSDocFunctionType();
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.DotDotDotToken:
|
||||
return parseJSDocVariadicType();
|
||||
case SyntaxKind.NewKeyword:
|
||||
@ -6091,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:
|
||||
@ -6752,7 +6754,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,10 +6,12 @@
|
||||
* @property {string=} y
|
||||
* @property {string} [z]
|
||||
* @property {string} [w="hi"]
|
||||
*
|
||||
*
|
||||
* @param {Opts} opts
|
||||
*/
|
||||
function foo(opts) {}
|
||||
function foo(opts) {
|
||||
opts.x;
|
||||
}
|
||||
|
||||
foo({x: 'abc'});
|
||||
|
||||
@ -20,9 +22,26 @@ foo({x: 'abc'});
|
||||
*
|
||||
* @param {AnotherOpts} opts
|
||||
*/
|
||||
function foo1(opts) {}
|
||||
function foo1(opts) {
|
||||
opts.anotherX;
|
||||
}
|
||||
|
||||
foo1({anotherX: "world"});
|
||||
foo1({anotherX: "world"});
|
||||
|
||||
/**
|
||||
* @typedef {object} Opts1
|
||||
* @property {string} x
|
||||
* @property {string=} y
|
||||
* @property {string} [z]
|
||||
* @property {string} [w="hi"]
|
||||
*
|
||||
* @param {Opts1} opts
|
||||
*/
|
||||
function foo2(opts) {
|
||||
opts.x;
|
||||
}
|
||||
foo2({x: 'abc'});
|
||||
|
||||
|
||||
//// [0.js]
|
||||
// @ts-check
|
||||
@ -35,7 +54,9 @@ foo1({anotherX: "world"});
|
||||
*
|
||||
* @param {Opts} opts
|
||||
*/
|
||||
function foo(opts) { }
|
||||
function foo(opts) {
|
||||
opts.x;
|
||||
}
|
||||
foo({ x: 'abc' });
|
||||
/**
|
||||
* @typedef {Object} AnotherOpts
|
||||
@ -44,5 +65,20 @@ foo({ x: 'abc' });
|
||||
*
|
||||
* @param {AnotherOpts} opts
|
||||
*/
|
||||
function foo1(opts) { }
|
||||
function foo1(opts) {
|
||||
opts.anotherX;
|
||||
}
|
||||
foo1({ anotherX: "world" });
|
||||
/**
|
||||
* @typedef {object} Opts1
|
||||
* @property {string} x
|
||||
* @property {string=} y
|
||||
* @property {string} [z]
|
||||
* @property {string} [w="hi"]
|
||||
*
|
||||
* @param {Opts1} opts
|
||||
*/
|
||||
function foo2(opts) {
|
||||
opts.x;
|
||||
}
|
||||
foo2({ x: 'abc' });
|
||||
|
||||
@ -6,16 +6,22 @@
|
||||
* @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} AnotherOpts
|
||||
@ -24,11 +30,39 @@ foo({x: 'abc'});
|
||||
*
|
||||
* @param {AnotherOpts} opts
|
||||
*/
|
||||
function foo1(opts) {}
|
||||
>foo1 : Symbol(foo1, Decl(0.js, 12, 16))
|
||||
>opts : Symbol(opts, Decl(0.js, 21, 14))
|
||||
function foo1(opts) {
|
||||
>foo1 : Symbol(foo1, Decl(0.js, 14, 16))
|
||||
>opts : Symbol(opts, Decl(0.js, 23, 14))
|
||||
|
||||
opts.anotherX;
|
||||
>opts.anotherX : Symbol(anotherX, Decl(0.js, 18, 3))
|
||||
>opts : Symbol(opts, Decl(0.js, 23, 14))
|
||||
>anotherX : Symbol(anotherX, Decl(0.js, 18, 3))
|
||||
}
|
||||
|
||||
foo1({anotherX: "world"});
|
||||
>foo1 : Symbol(foo1, Decl(0.js, 12, 16))
|
||||
>anotherX : Symbol(anotherX, Decl(0.js, 23, 6))
|
||||
>foo1 : Symbol(foo1, Decl(0.js, 14, 16))
|
||||
>anotherX : Symbol(anotherX, Decl(0.js, 27, 6))
|
||||
|
||||
/**
|
||||
* @typedef {object} Opts1
|
||||
* @property {string} x
|
||||
* @property {string=} y
|
||||
* @property {string} [z]
|
||||
* @property {string} [w="hi"]
|
||||
*
|
||||
* @param {Opts1} opts
|
||||
*/
|
||||
function foo2(opts) {
|
||||
>foo2 : Symbol(foo2, Decl(0.js, 27, 26))
|
||||
>opts : Symbol(opts, Decl(0.js, 38, 14))
|
||||
|
||||
opts.x;
|
||||
>opts.x : Symbol(x, Decl(0.js, 31, 3))
|
||||
>opts : Symbol(opts, Decl(0.js, 38, 14))
|
||||
>x : Symbol(x, Decl(0.js, 31, 3))
|
||||
}
|
||||
foo2({x: 'abc'});
|
||||
>foo2 : Symbol(foo2, Decl(0.js, 27, 26))
|
||||
>x : Symbol(x, Decl(0.js, 41, 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
|
||||
@ -27,10 +33,16 @@ foo({x: 'abc'});
|
||||
*
|
||||
* @param {AnotherOpts} opts
|
||||
*/
|
||||
function foo1(opts) {}
|
||||
function foo1(opts) {
|
||||
>foo1 : (opts: { anotherX: string; anotherY?: string; }) => void
|
||||
>opts : { anotherX: string; anotherY?: string; }
|
||||
|
||||
opts.anotherX;
|
||||
>opts.anotherX : string
|
||||
>opts : { anotherX: string; anotherY?: string; }
|
||||
>anotherX : string
|
||||
}
|
||||
|
||||
foo1({anotherX: "world"});
|
||||
>foo1({anotherX: "world"}) : void
|
||||
>foo1 : (opts: { anotherX: string; anotherY?: string; }) => void
|
||||
@ -38,3 +50,28 @@ foo1({anotherX: "world"});
|
||||
>anotherX : string
|
||||
>"world" : "world"
|
||||
|
||||
/**
|
||||
* @typedef {object} Opts1
|
||||
* @property {string} x
|
||||
* @property {string=} y
|
||||
* @property {string} [z]
|
||||
* @property {string} [w="hi"]
|
||||
*
|
||||
* @param {Opts1} opts
|
||||
*/
|
||||
function foo2(opts) {
|
||||
>foo2 : (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
|
||||
}
|
||||
foo2({x: 'abc'});
|
||||
>foo2({x: 'abc'}) : void
|
||||
>foo2 : (opts: { x: string; y?: string; z?: string; w?: string; }) => void
|
||||
>{x: 'abc'} : { x: string; }
|
||||
>x : string
|
||||
>'abc' : "abc"
|
||||
|
||||
|
||||
@ -431,28 +431,8 @@
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "(",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": ")",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "=>",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "any",
|
||||
"kind": "keyword"
|
||||
"text": "Function",
|
||||
"kind": "localName"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
|
||||
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": []
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -11,6 +11,10 @@ anyT1 = "hi";
|
||||
const x = (a) => a + 1;
|
||||
x(1);
|
||||
|
||||
/** @type {function} */
|
||||
const y = (a) => a + 1;
|
||||
x(1);
|
||||
|
||||
/** @type {function (number)} */
|
||||
const x1 = (a) => a + 1;
|
||||
x1(0);
|
||||
@ -29,6 +33,9 @@ anyT1 = "hi";
|
||||
/** @type {Function} */
|
||||
var x = function (a) { return a + 1; };
|
||||
x(1);
|
||||
/** @type {function} */
|
||||
var y = function (a) { return a + 1; };
|
||||
x(1);
|
||||
/** @type {function (number)} */
|
||||
var x1 = function (a) { return a + 1; };
|
||||
x1(0);
|
||||
|
||||
@ -20,21 +20,30 @@ const x = (a) => a + 1;
|
||||
x(1);
|
||||
>x : Symbol(x, Decl(0.js, 9, 5))
|
||||
|
||||
/** @type {function} */
|
||||
const y = (a) => a + 1;
|
||||
>y : Symbol(y, Decl(0.js, 13, 5))
|
||||
>a : Symbol(a, Decl(0.js, 13, 11))
|
||||
>a : Symbol(a, Decl(0.js, 13, 11))
|
||||
|
||||
x(1);
|
||||
>x : Symbol(x, Decl(0.js, 9, 5))
|
||||
|
||||
/** @type {function (number)} */
|
||||
const x1 = (a) => a + 1;
|
||||
>x1 : Symbol(x1, Decl(0.js, 13, 5))
|
||||
>a : Symbol(a, Decl(0.js, 13, 12))
|
||||
>a : Symbol(a, Decl(0.js, 13, 12))
|
||||
>x1 : Symbol(x1, Decl(0.js, 17, 5))
|
||||
>a : Symbol(a, Decl(0.js, 17, 12))
|
||||
>a : Symbol(a, Decl(0.js, 17, 12))
|
||||
|
||||
x1(0);
|
||||
>x1 : Symbol(x1, Decl(0.js, 13, 5))
|
||||
>x1 : Symbol(x1, Decl(0.js, 17, 5))
|
||||
|
||||
/** @type {function (number): number} */
|
||||
const x2 = (a) => a + 1;
|
||||
>x2 : Symbol(x2, Decl(0.js, 17, 5))
|
||||
>a : Symbol(a, Decl(0.js, 17, 12))
|
||||
>a : Symbol(a, Decl(0.js, 17, 12))
|
||||
>x2 : Symbol(x2, Decl(0.js, 21, 5))
|
||||
>a : Symbol(a, Decl(0.js, 21, 12))
|
||||
>a : Symbol(a, Decl(0.js, 21, 12))
|
||||
|
||||
x2(0);
|
||||
>x2 : Symbol(x2, Decl(0.js, 17, 5))
|
||||
>x2 : Symbol(x2, Decl(0.js, 21, 5))
|
||||
|
||||
|
||||
@ -29,6 +29,20 @@ x(1);
|
||||
>x : Function
|
||||
>1 : 1
|
||||
|
||||
/** @type {function} */
|
||||
const y = (a) => a + 1;
|
||||
>y : Function
|
||||
>(a) => a + 1 : (a: any) => any
|
||||
>a : any
|
||||
>a + 1 : any
|
||||
>a : any
|
||||
>1 : 1
|
||||
|
||||
x(1);
|
||||
>x(1) : any
|
||||
>x : Function
|
||||
>1 : 1
|
||||
|
||||
/** @type {function (number)} */
|
||||
const x1 = (a) => a + 1;
|
||||
>x1 : (arg0: number) => any
|
||||
|
||||
@ -9,10 +9,12 @@
|
||||
* @property {string=} y
|
||||
* @property {string} [z]
|
||||
* @property {string} [w="hi"]
|
||||
*
|
||||
*
|
||||
* @param {Opts} opts
|
||||
*/
|
||||
function foo(opts) {}
|
||||
function foo(opts) {
|
||||
opts.x;
|
||||
}
|
||||
|
||||
foo({x: 'abc'});
|
||||
|
||||
@ -23,6 +25,22 @@ foo({x: 'abc'});
|
||||
*
|
||||
* @param {AnotherOpts} opts
|
||||
*/
|
||||
function foo1(opts) {}
|
||||
function foo1(opts) {
|
||||
opts.anotherX;
|
||||
}
|
||||
|
||||
foo1({anotherX: "world"});
|
||||
foo1({anotherX: "world"});
|
||||
|
||||
/**
|
||||
* @typedef {object} Opts1
|
||||
* @property {string} x
|
||||
* @property {string=} y
|
||||
* @property {string} [z]
|
||||
* @property {string} [w="hi"]
|
||||
*
|
||||
* @param {Opts1} opts
|
||||
*/
|
||||
function foo2(opts) {
|
||||
opts.x;
|
||||
}
|
||||
foo2({x: 'abc'});
|
||||
|
||||
@ -14,6 +14,10 @@ anyT1 = "hi";
|
||||
const x = (a) => a + 1;
|
||||
x(1);
|
||||
|
||||
/** @type {function} */
|
||||
const y = (a) => a + 1;
|
||||
x(1);
|
||||
|
||||
/** @type {function (number)} */
|
||||
const x1 = (a) => a + 1;
|
||||
x1(0);
|
||||
|
||||
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();
|
||||
Loading…
x
Reference in New Issue
Block a user