Closed as not planned
Closed as not planned
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have searched for related issues and found none that matched my issue.
- I have read the FAQ and my problem is not listed.
Relevant Package
parser
Playground Link
Repro Code
function f1(a: any): a is string!{
return true;
}
ESLint Config
tsconfig
Expected Result
{
"type": "Program",
"start": 0,
"end": 51,
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 51,
"id": {
"type": "Identifier",
"start": 9,
"end": 11,
"name": "f1",
"decorators": [],
"optional": false,
"typeAnnotation": null
},
"expression": false,
"generator": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 12,
"end": 18,
"name": "a",
"decorators": [],
"optional": false,
"typeAnnotation": {
"type": "TSTypeAnnotation",
"start": 13,
"end": 18,
"typeAnnotation": {
"type": "TSAnyKeyword",
"start": 15,
"end": 18
}
}
}
],
"body": {
"type": "BlockStatement",
"start": 33,
"end": 51,
"body": [
{
"type": "ReturnStatement",
"start": 37,
"end": 49,
"argument": {
"type": "Literal",
"start": 44,
"end": 48,
"value": true,
"raw": "true"
}
}
]
},
"declare": false,
"typeParameters": null,
"returnType": {
"type": "TSTypeAnnotation",
"start": 19,
"end": 33,
"typeAnnotation": {
"type": "TSTypePredicate",
"start": 21,
"end": 33,
"parameterName": {
"type": "Identifier",
"start": 21,
"end": 22,
"name": "a",
"decorators": [],
"optional": false,
"typeAnnotation": null
},
"asserts": false,
"typeAnnotation": { // ============================== 👀
"type": "TSTypeAnnotation",
"start": 26,
"end": 33,
"typeAnnotation": {
"type": "TSJSDocNonNullableType",
"start": 26,
"end": 33,
"typeAnnotation": {
"type": "TSStringKeyword",
"start": 26,
"end": 32
},
"postfix": true
} // ============================================= 👀
}
}
}
}
],
"sourceType": "module"
}
Actual Result
{
"type": "Program",
"start": 0,
"end": 51,
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 51,
"async": false,
"body": {
"type": "BlockStatement",
"start": 33,
"end": 51,
"body": [
{
"type": "ReturnStatement",
"start": 37,
"end": 49,
"argument": {
"type": "Literal",
"start": 44,
"end": 48,
"raw": "true",
"value": true
}
}
]
},
"declare": false,
"expression": false,
"generator": false,
"id": {
"type": "Identifier",
"start": 9,
"end": 11,
"decorators": [],
"name": "f1",
"optional": false,
"typeAnnotation": null
},
"params": [
{
"type": "Identifier",
"start": 12,
"end": 18,
"decorators": [],
"name": "a",
"optional": false,
"typeAnnotation": {
"type": "TSTypeAnnotation",
"start": 13,
"end": 18,
"typeAnnotation": {
"type": "TSAnyKeyword",
"start": 15,
"end": 18
}
}
}
],
"returnType": {
"type": "TSTypeAnnotation",
"start": 19,
"end": 33,
"typeAnnotation": {
"type": "TSTypePredicate",
"start": 21,
"end": 33,
"asserts": false,
"parameterName": {
"type": "Identifier",
"start": 21,
"end": 22,
"decorators": [],
"name": "a",
"optional": false,
"typeAnnotation": null
},
"typeAnnotation": { // ============================== 👀
"type": "TSTypeAnnotation",
"start": 26,
"end": 33,
"typeAnnotation": {
"type": "TSJSDocNonNullableType",
"start": 26,
"end": 33,
"typeAnnotation": {
"type": "TSTypeAnnotation",
"start": 24, // ❗️
"end": 32,
"typeAnnotation": {
"type": "TSStringKeyword",
"start": 26,
"end": 32
}
},
"id": 0,
"original": null,
"emitNode": null,
"postfix": true
}
}
} // ================================================== 👀
},
"typeParameters": null
}
],
"sourceType": "module"
}
Additional Info
I'm not sure if extra typeAnnotation
nesting is intended or not, but at least its starting position should be fixed?
Versions
package | version |
---|---|
@typescript-eslint/parser |
8.29.1 |