Merge pull request #16052 from Microsoft/master-fix15825
[Master] fix 15825
This commit is contained in:
commit
21a35b256d
|
@ -2818,9 +2818,11 @@ namespace ts {
|
|||
const parameterDeclaration = getDeclarationOfKind<ParameterDeclaration>(parameterSymbol, SyntaxKind.Parameter);
|
||||
const modifiers = parameterDeclaration.modifiers && parameterDeclaration.modifiers.map(getSynthesizedClone);
|
||||
const dotDotDotToken = isRestParameter(parameterDeclaration) ? createToken(SyntaxKind.DotDotDotToken) : undefined;
|
||||
const name = parameterDeclaration.name.kind === SyntaxKind.Identifier ?
|
||||
const name = parameterDeclaration.name ?
|
||||
parameterDeclaration.name.kind === SyntaxKind.Identifier ?
|
||||
setEmitFlags(getSynthesizedClone(parameterDeclaration.name), EmitFlags.NoAsciiEscaping) :
|
||||
cloneBindingName(parameterDeclaration.name);
|
||||
cloneBindingName(parameterDeclaration.name) :
|
||||
parameterSymbol.name;
|
||||
const questionToken = isOptionalParameter(parameterDeclaration) ? createToken(SyntaxKind.QuestionToken) : undefined;
|
||||
|
||||
let parameterType = getTypeOfSymbol(parameterSymbol);
|
||||
|
@ -6696,8 +6698,10 @@ namespace ts {
|
|||
return length(type.target.typeParameters);
|
||||
}
|
||||
|
||||
// Get type from reference to class or interface
|
||||
function getTypeFromClassOrInterfaceReference(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference, symbol: Symbol, typeArgs: Type[]): Type {
|
||||
/**
|
||||
* Get type from type-reference that reference to class or interface
|
||||
*/
|
||||
function getTypeFromClassOrInterfaceReference(node: TypeReferenceType, symbol: Symbol, typeArgs: Type[]): Type {
|
||||
const type = <InterfaceType>getDeclaredTypeOfSymbol(getMergedSymbol(symbol));
|
||||
const typeParameters = type.localTypeParameters;
|
||||
if (typeParameters) {
|
||||
|
@ -6738,10 +6742,12 @@ namespace ts {
|
|||
return instantiation;
|
||||
}
|
||||
|
||||
// Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include
|
||||
// references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the
|
||||
// declared type. Instantiations are cached using the type identities of the type arguments as the key.
|
||||
function getTypeFromTypeAliasReference(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference, symbol: Symbol, typeArguments: Type[]): Type {
|
||||
/**
|
||||
* Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include
|
||||
* references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the
|
||||
* declared type. Instantiations are cached using the type identities of the type arguments as the key.
|
||||
*/
|
||||
function getTypeFromTypeAliasReference(node: TypeReferenceType, symbol: Symbol, typeArguments: Type[]): Type {
|
||||
const type = getDeclaredTypeOfSymbol(symbol);
|
||||
const typeParameters = getSymbolLinks(symbol).typeParameters;
|
||||
if (typeParameters) {
|
||||
|
@ -6766,8 +6772,10 @@ namespace ts {
|
|||
return type;
|
||||
}
|
||||
|
||||
// Get type from reference to named type that cannot be generic (enum or type parameter)
|
||||
function getTypeFromNonGenericTypeReference(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference, symbol: Symbol): Type {
|
||||
/**
|
||||
* Get type from reference to named type that cannot be generic (enum or type parameter)
|
||||
*/
|
||||
function getTypeFromNonGenericTypeReference(node: TypeReferenceType, symbol: Symbol): Type {
|
||||
if (node.typeArguments) {
|
||||
error(node, Diagnostics.Type_0_is_not_generic, symbolToString(symbol));
|
||||
return unknownType;
|
||||
|
@ -6775,7 +6783,7 @@ namespace ts {
|
|||
return getDeclaredTypeOfSymbol(symbol);
|
||||
}
|
||||
|
||||
function getTypeReferenceName(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference): EntityNameOrEntityNameExpression | undefined {
|
||||
function getTypeReferenceName(node: TypeReferenceType): EntityNameOrEntityNameExpression | undefined {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.TypeReference:
|
||||
return (<TypeReferenceNode>node).typeName;
|
||||
|
@ -6803,7 +6811,7 @@ namespace ts {
|
|||
return resolveEntityName(typeReferenceName, SymbolFlags.Type) || unknownSymbol;
|
||||
}
|
||||
|
||||
function getTypeReferenceType(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference, symbol: Symbol) {
|
||||
function getTypeReferenceType(node: TypeReferenceType, symbol: Symbol) {
|
||||
const typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced.
|
||||
|
||||
if (symbol === unknownSymbol) {
|
||||
|
@ -6846,7 +6854,7 @@ namespace ts {
|
|||
case "Object":
|
||||
return anyType;
|
||||
case "Function":
|
||||
return anyFunctionType;
|
||||
return globalFunctionType;
|
||||
case "Array":
|
||||
case "array":
|
||||
return !node.typeArguments || !node.typeArguments.length ? createArrayType(anyType) : undefined;
|
||||
|
@ -6862,7 +6870,7 @@ namespace ts {
|
|||
return strictNullChecks ? getUnionType([type, nullType]) : type;
|
||||
}
|
||||
|
||||
function getTypeFromTypeReference(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference): Type {
|
||||
function getTypeFromTypeReference(node: TypeReferenceType): Type {
|
||||
const links = getNodeLinks(node);
|
||||
if (!links.resolvedType) {
|
||||
let symbol: Symbol;
|
||||
|
@ -6893,7 +6901,7 @@ namespace ts {
|
|||
return links.resolvedType;
|
||||
}
|
||||
|
||||
function typeArgumentsFromTypeReferenceNode(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference): Type[] {
|
||||
function typeArgumentsFromTypeReferenceNode(node: TypeReferenceType): Type[] {
|
||||
return map(node.typeArguments, getTypeFromTypeNode);
|
||||
}
|
||||
|
||||
|
|
|
@ -892,6 +892,8 @@ namespace ts {
|
|||
kind: SyntaxKind.ConstructorType;
|
||||
}
|
||||
|
||||
export type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference;
|
||||
|
||||
export interface TypeReferenceNode extends TypeNode {
|
||||
kind: SyntaxKind.TypeReference;
|
||||
typeName: EntityName;
|
||||
|
|
584
tests/baselines/reference/jsDocTypeTag1.js
Normal file
584
tests/baselines/reference/jsDocTypeTag1.js
Normal file
|
@ -0,0 +1,584 @@
|
|||
[
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
|
||||
"position": 26
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 26,
|
||||
"length": 1
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "S",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "string",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
|
||||
"position": 55
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 55,
|
||||
"length": 1
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "N",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "number",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
|
||||
"position": 85
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 85,
|
||||
"length": 1
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "B",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "boolean",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
|
||||
"position": 112
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 112,
|
||||
"length": 1
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "V",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "void",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
|
||||
"position": 144
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 144,
|
||||
"length": 1
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "U",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "undefined",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
|
||||
"position": 171
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 171,
|
||||
"length": 2
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "Nl",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "null",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
|
||||
"position": 200
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 200,
|
||||
"length": 1
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "A",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "any",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": "[",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
"kind": "punctuation"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
|
||||
"position": 230
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 230,
|
||||
"length": 1
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "P",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "Promise",
|
||||
"kind": "interfaceName"
|
||||
},
|
||||
{
|
||||
"text": "<",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "any",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": ">",
|
||||
"kind": "punctuation"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
|
||||
"position": 259
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 259,
|
||||
"length": 3
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "Obj",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "any",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
|
||||
"position": 292
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 292,
|
||||
"length": 4
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "Func",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "Function",
|
||||
"kind": "localName"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
|
||||
"position": 319
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 319,
|
||||
"length": 7
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "AnyType",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "any",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
|
||||
"position": 349
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 349,
|
||||
"length": 5
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "QType",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "any",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
|
||||
"position": 389
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 389,
|
||||
"length": 4
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "SOrN",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "string",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "|",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "number",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
}
|
||||
]
|
598
tests/baselines/reference/jsDocTypeTag2.js
Normal file
598
tests/baselines/reference/jsDocTypeTag2.js
Normal file
|
@ -0,0 +1,598 @@
|
|||
[
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
|
||||
"position": 26
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 26,
|
||||
"length": 1
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "s",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "string",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
|
||||
"position": 55
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 55,
|
||||
"length": 1
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "n",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "number",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
|
||||
"position": 85
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 85,
|
||||
"length": 1
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "b",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "boolean",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
|
||||
"position": 112
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 112,
|
||||
"length": 1
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "v",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "void",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
|
||||
"position": 144
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 144,
|
||||
"length": 1
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "u",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "undefined",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
|
||||
"position": 171
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 171,
|
||||
"length": 2
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "nl",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "null",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
|
||||
"position": 200
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 200,
|
||||
"length": 1
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "a",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "any",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": "[",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
"kind": "punctuation"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
|
||||
"position": 230
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 230,
|
||||
"length": 1
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "p",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "Promise",
|
||||
"kind": "interfaceName"
|
||||
},
|
||||
{
|
||||
"text": "<",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "any",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": ">",
|
||||
"kind": "punctuation"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
|
||||
"position": 260
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 260,
|
||||
"length": 8
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "nullable",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "number",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
|
||||
"position": 298
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 298,
|
||||
"length": 4
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "func",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "(",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": ")",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "=>",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "any",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
|
||||
"position": 349
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 349,
|
||||
"length": 5
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "func1",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "(",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "arg0",
|
||||
"kind": "parameterName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "number",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": ")",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "=>",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "number",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
|
||||
"position": 391
|
||||
},
|
||||
"quickInfo": {
|
||||
"kind": "var",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 391,
|
||||
"length": 4
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "var",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "sOrn",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "string",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "|",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "number",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": []
|
||||
}
|
||||
}
|
||||
]
|
37
tests/baselines/reference/jsDocTypes2.js
Normal file
37
tests/baselines/reference/jsDocTypes2.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
//// [0.js]
|
||||
// @ts-check
|
||||
/** @type {*} */
|
||||
var anyT = 2;
|
||||
|
||||
/** @type {?} */
|
||||
var anyT1 = 2;
|
||||
anyT1 = "hi";
|
||||
|
||||
/** @type {Function} */
|
||||
const x = (a) => a + 1;
|
||||
x(1);
|
||||
|
||||
/** @type {function (number)} */
|
||||
const x1 = (a) => a + 1;
|
||||
x1(0);
|
||||
|
||||
/** @type {function (number): number} */
|
||||
const x2 = (a) => a + 1;
|
||||
x2(0);
|
||||
|
||||
//// [0.js]
|
||||
// @ts-check
|
||||
/** @type {*} */
|
||||
var anyT = 2;
|
||||
/** @type {?} */
|
||||
var anyT1 = 2;
|
||||
anyT1 = "hi";
|
||||
/** @type {Function} */
|
||||
var x = function (a) { return a + 1; };
|
||||
x(1);
|
||||
/** @type {function (number)} */
|
||||
var x1 = function (a) { return a + 1; };
|
||||
x1(0);
|
||||
/** @type {function (number): number} */
|
||||
var x2 = function (a) { return a + 1; };
|
||||
x2(0);
|
40
tests/baselines/reference/jsDocTypes2.symbols
Normal file
40
tests/baselines/reference/jsDocTypes2.symbols
Normal file
|
@ -0,0 +1,40 @@
|
|||
=== tests/cases/conformance/salsa/0.js ===
|
||||
// @ts-check
|
||||
/** @type {*} */
|
||||
var anyT = 2;
|
||||
>anyT : Symbol(anyT, Decl(0.js, 2, 3))
|
||||
|
||||
/** @type {?} */
|
||||
var anyT1 = 2;
|
||||
>anyT1 : Symbol(anyT1, Decl(0.js, 5, 3))
|
||||
|
||||
anyT1 = "hi";
|
||||
>anyT1 : Symbol(anyT1, Decl(0.js, 5, 3))
|
||||
|
||||
/** @type {Function} */
|
||||
const x = (a) => a + 1;
|
||||
>x : Symbol(x, Decl(0.js, 9, 5))
|
||||
>a : Symbol(a, Decl(0.js, 9, 11))
|
||||
>a : Symbol(a, Decl(0.js, 9, 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(0);
|
||||
>x1 : Symbol(x1, Decl(0.js, 13, 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(0);
|
||||
>x2 : Symbol(x2, Decl(0.js, 17, 5))
|
||||
|
59
tests/baselines/reference/jsDocTypes2.types
Normal file
59
tests/baselines/reference/jsDocTypes2.types
Normal file
|
@ -0,0 +1,59 @@
|
|||
=== tests/cases/conformance/salsa/0.js ===
|
||||
// @ts-check
|
||||
/** @type {*} */
|
||||
var anyT = 2;
|
||||
>anyT : any
|
||||
>2 : 2
|
||||
|
||||
/** @type {?} */
|
||||
var anyT1 = 2;
|
||||
>anyT1 : any
|
||||
>2 : 2
|
||||
|
||||
anyT1 = "hi";
|
||||
>anyT1 = "hi" : "hi"
|
||||
>anyT1 : any
|
||||
>"hi" : "hi"
|
||||
|
||||
/** @type {Function} */
|
||||
const x = (a) => a + 1;
|
||||
>x : 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
|
||||
>(a) => a + 1 : (a: any) => any
|
||||
>a : any
|
||||
>a + 1 : any
|
||||
>a : any
|
||||
>1 : 1
|
||||
|
||||
x1(0);
|
||||
>x1(0) : any
|
||||
>x1 : (arg0: number) => any
|
||||
>0 : 0
|
||||
|
||||
/** @type {function (number): number} */
|
||||
const x2 = (a) => a + 1;
|
||||
>x2 : (arg0: number) => number
|
||||
>(a) => a + 1 : (a: any) => any
|
||||
>a : any
|
||||
>a + 1 : any
|
||||
>a : any
|
||||
>1 : 1
|
||||
|
||||
x2(0);
|
||||
>x2(0) : number
|
||||
>x2 : (arg0: number) => number
|
||||
>0 : 0
|
||||
|
21
tests/baselines/reference/jsDocTypes3.errors.txt
Normal file
21
tests/baselines/reference/jsDocTypes3.errors.txt
Normal file
|
@ -0,0 +1,21 @@
|
|||
tests/cases/conformance/salsa/0.js(5,4): error TS2345: Argument of type '"string"' is not assignable to parameter of type 'number'.
|
||||
tests/cases/conformance/salsa/0.js(12,1): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/salsa/0.js (2 errors) ====
|
||||
// @ts-check
|
||||
|
||||
/** @type {function (number)} */
|
||||
const x1 = (a) => a + 1;
|
||||
x1("string");
|
||||
~~~~~~~~
|
||||
!!! error TS2345: Argument of type '"string"' is not assignable to parameter of type 'number'.
|
||||
|
||||
/** @type {function (number): number} */
|
||||
const x2 = (a) => a + 1;
|
||||
|
||||
/** @type {string} */
|
||||
var a;
|
||||
a = x2(0);
|
||||
~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
24
tests/baselines/reference/jsDocTypes3.js
Normal file
24
tests/baselines/reference/jsDocTypes3.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
//// [0.js]
|
||||
// @ts-check
|
||||
|
||||
/** @type {function (number)} */
|
||||
const x1 = (a) => a + 1;
|
||||
x1("string");
|
||||
|
||||
/** @type {function (number): number} */
|
||||
const x2 = (a) => a + 1;
|
||||
|
||||
/** @type {string} */
|
||||
var a;
|
||||
a = x2(0);
|
||||
|
||||
//// [0.js]
|
||||
// @ts-check
|
||||
/** @type {function (number)} */
|
||||
var x1 = function (a) { return a + 1; };
|
||||
x1("string");
|
||||
/** @type {function (number): number} */
|
||||
var x2 = function (a) { return a + 1; };
|
||||
/** @type {string} */
|
||||
var a;
|
||||
a = x2(0);
|
|
@ -10,8 +10,8 @@
|
|||
* @returns {*} Returns the result of `func`.
|
||||
*/
|
||||
function apply(func, thisArg, args) {
|
||||
>apply : (func: {}, thisArg: any, ...args: any[]) => any
|
||||
>func : {}
|
||||
>apply : (func: Function, thisArg: any, ...args: any[]) => any
|
||||
>func : Function
|
||||
>thisArg : any
|
||||
>args : any[]
|
||||
|
||||
|
@ -28,7 +28,7 @@ function apply(func, thisArg, args) {
|
|||
>0 : 0
|
||||
>func.call(thisArg) : any
|
||||
>func.call : (this: Function, thisArg: any, ...argArray: any[]) => any
|
||||
>func : {}
|
||||
>func : Function
|
||||
>call : (this: Function, thisArg: any, ...argArray: any[]) => any
|
||||
>thisArg : any
|
||||
|
||||
|
@ -36,7 +36,7 @@ function apply(func, thisArg, args) {
|
|||
>1 : 1
|
||||
>func.call(thisArg, args[0]) : any
|
||||
>func.call : (this: Function, thisArg: any, ...argArray: any[]) => any
|
||||
>func : {}
|
||||
>func : Function
|
||||
>call : (this: Function, thisArg: any, ...argArray: any[]) => any
|
||||
>thisArg : any
|
||||
>args[0] : any
|
||||
|
@ -47,7 +47,7 @@ function apply(func, thisArg, args) {
|
|||
>2 : 2
|
||||
>func.call(thisArg, args[0], args[1]) : any
|
||||
>func.call : (this: Function, thisArg: any, ...argArray: any[]) => any
|
||||
>func : {}
|
||||
>func : Function
|
||||
>call : (this: Function, thisArg: any, ...argArray: any[]) => any
|
||||
>thisArg : any
|
||||
>args[0] : any
|
||||
|
@ -61,7 +61,7 @@ function apply(func, thisArg, args) {
|
|||
>3 : 3
|
||||
>func.call(thisArg, args[0], args[1], args[2]) : any
|
||||
>func.call : (this: Function, thisArg: any, ...argArray: any[]) => any
|
||||
>func : {}
|
||||
>func : Function
|
||||
>call : (this: Function, thisArg: any, ...argArray: any[]) => any
|
||||
>thisArg : any
|
||||
>args[0] : any
|
||||
|
@ -77,12 +77,12 @@ function apply(func, thisArg, args) {
|
|||
return func.apply(thisArg, args);
|
||||
>func.apply(thisArg, args) : any
|
||||
>func.apply : (this: Function, thisArg: any, argArray?: any) => any
|
||||
>func : {}
|
||||
>func : Function
|
||||
>apply : (this: Function, thisArg: any, argArray?: any) => any
|
||||
>thisArg : any
|
||||
>args : any[]
|
||||
}
|
||||
|
||||
export default apply;
|
||||
>apply : (func: {}, thisArg: any, ...args: any[]) => any
|
||||
>apply : (func: Function, thisArg: any, ...args: any[]) => any
|
||||
|
||||
|
|
23
tests/cases/conformance/salsa/jsDocTypes2.ts
Normal file
23
tests/cases/conformance/salsa/jsDocTypes2.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
// @allowJS: true
|
||||
// @suppressOutputPathCheck: true
|
||||
|
||||
// @filename: 0.js
|
||||
// @ts-check
|
||||
/** @type {*} */
|
||||
var anyT = 2;
|
||||
|
||||
/** @type {?} */
|
||||
var anyT1 = 2;
|
||||
anyT1 = "hi";
|
||||
|
||||
/** @type {Function} */
|
||||
const x = (a) => a + 1;
|
||||
x(1);
|
||||
|
||||
/** @type {function (number)} */
|
||||
const x1 = (a) => a + 1;
|
||||
x1(0);
|
||||
|
||||
/** @type {function (number): number} */
|
||||
const x2 = (a) => a + 1;
|
||||
x2(0);
|
16
tests/cases/conformance/salsa/jsDocTypes3.ts
Normal file
16
tests/cases/conformance/salsa/jsDocTypes3.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
// @allowJS: true
|
||||
// @suppressOutputPathCheck: true
|
||||
|
||||
// @filename: 0.js
|
||||
// @ts-check
|
||||
|
||||
/** @type {function (number)} */
|
||||
const x1 = (a) => a + 1;
|
||||
x1("string");
|
||||
|
||||
/** @type {function (number): number} */
|
||||
const x2 = (a) => a + 1;
|
||||
|
||||
/** @type {string} */
|
||||
var a;
|
||||
a = x2(0);
|
43
tests/cases/fourslash/jsDocTypeTagQuickInfo1.ts
Normal file
43
tests/cases/fourslash/jsDocTypeTagQuickInfo1.ts
Normal file
|
@ -0,0 +1,43 @@
|
|||
/// <reference path="fourslash.ts" />
|
||||
// @allowJs: true
|
||||
// @Filename: jsDocTypeTag1.js
|
||||
//// /** @type {String} */
|
||||
//// var /*1*/S;
|
||||
|
||||
//// /** @type {Number} */
|
||||
//// var /*2*/N;
|
||||
|
||||
//// /** @type {Boolean} */
|
||||
//// var /*3*/B;
|
||||
|
||||
//// /** @type {Void} */
|
||||
//// var /*4*/V;
|
||||
|
||||
//// /** @type {Undefined} */
|
||||
//// var /*5*/U;
|
||||
|
||||
//// /** @type {Null} */
|
||||
//// var /*6*/Nl;
|
||||
|
||||
//// /** @type {Array} */
|
||||
//// var /*7*/A;
|
||||
|
||||
//// /** @type {Promise} */
|
||||
//// var /*8*/P;
|
||||
|
||||
//// /** @type {Object} */
|
||||
//// var /*9*/Obj;
|
||||
|
||||
//// /** @type {Function} */
|
||||
//// var /*10*/Func;
|
||||
|
||||
//// /** @type {*} */
|
||||
//// var /*11*/AnyType;
|
||||
|
||||
//// /** @type {?} */
|
||||
//// var /*12*/QType;
|
||||
|
||||
//// /** @type {String|Number} */
|
||||
//// var /*13*/SOrN;
|
||||
|
||||
verify.baselineQuickInfo();
|
40
tests/cases/fourslash/jsDocTypeTagQuickInfo2.ts
Normal file
40
tests/cases/fourslash/jsDocTypeTagQuickInfo2.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
/// <reference path="fourslash.ts" />
|
||||
// @allowJs: true
|
||||
// @Filename: jsDocTypeTag2.js
|
||||
//// /** @type {string} */
|
||||
//// var /*1*/s;
|
||||
|
||||
//// /** @type {number} */
|
||||
//// var /*2*/n;
|
||||
|
||||
//// /** @type {boolean} */
|
||||
//// var /*3*/b;
|
||||
|
||||
//// /** @type {void} */
|
||||
//// var /*4*/v;
|
||||
|
||||
//// /** @type {undefined} */
|
||||
//// var /*5*/u;
|
||||
|
||||
//// /** @type {null} */
|
||||
//// var /*6*/nl;
|
||||
|
||||
//// /** @type {array} */
|
||||
//// var /*7*/a;
|
||||
|
||||
//// /** @type {promise} */
|
||||
//// var /*8*/p;
|
||||
|
||||
//// /** @type {?number} */
|
||||
//// var /*9*/nullable;
|
||||
|
||||
//// /** @type {function} */
|
||||
//// var /*10*/func;
|
||||
|
||||
//// /** @type {function (number): number} */
|
||||
//// var /*11*/func1;
|
||||
|
||||
//// /** @type {string | number} */
|
||||
//// var /*12*/sOrn;
|
||||
|
||||
verify.baselineQuickInfo();
|
Loading…
Reference in a new issue