-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed a crash when inferring return type of an accessor with errors i…
…n its return statement (#56258)
- Loading branch information
Showing
6 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
tests/baselines/reference/accessorInferredReturnTypeErrorInReturnStatement.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
accessorInferredReturnTypeErrorInReturnStatement.ts(2,7): error TS7023: 'primaryPath' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. | ||
accessorInferredReturnTypeErrorInReturnStatement.ts(4,18): error TS2339: Property 'collection' does not exist on type '{ readonly primaryPath: any; }'. | ||
|
||
|
||
==== accessorInferredReturnTypeErrorInReturnStatement.ts (2 errors) ==== | ||
export var basePrototype = { | ||
get primaryPath() { | ||
~~~~~~~~~~~ | ||
!!! error TS7023: 'primaryPath' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. | ||
var _this = this; | ||
return _this.collection.schema.primaryPath; | ||
~~~~~~~~~~ | ||
!!! error TS2339: Property 'collection' does not exist on type '{ readonly primaryPath: any; }'. | ||
}, | ||
}; | ||
|
27 changes: 27 additions & 0 deletions
27
tests/baselines/reference/accessorInferredReturnTypeErrorInReturnStatement.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//// [tests/cases/compiler/accessorInferredReturnTypeErrorInReturnStatement.ts] //// | ||
|
||
//// [accessorInferredReturnTypeErrorInReturnStatement.ts] | ||
export var basePrototype = { | ||
get primaryPath() { | ||
var _this = this; | ||
return _this.collection.schema.primaryPath; | ||
}, | ||
}; | ||
|
||
|
||
//// [accessorInferredReturnTypeErrorInReturnStatement.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.basePrototype = void 0; | ||
exports.basePrototype = { | ||
get primaryPath() { | ||
var _this = this; | ||
return _this.collection.schema.primaryPath; | ||
}, | ||
}; | ||
|
||
|
||
//// [accessorInferredReturnTypeErrorInReturnStatement.d.ts] | ||
export declare var basePrototype: { | ||
readonly primaryPath: any; | ||
}; |
19 changes: 19 additions & 0 deletions
19
tests/baselines/reference/accessorInferredReturnTypeErrorInReturnStatement.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//// [tests/cases/compiler/accessorInferredReturnTypeErrorInReturnStatement.ts] //// | ||
|
||
=== accessorInferredReturnTypeErrorInReturnStatement.ts === | ||
export var basePrototype = { | ||
>basePrototype : Symbol(basePrototype, Decl(accessorInferredReturnTypeErrorInReturnStatement.ts, 0, 10)) | ||
|
||
get primaryPath() { | ||
>primaryPath : Symbol(primaryPath, Decl(accessorInferredReturnTypeErrorInReturnStatement.ts, 0, 28)) | ||
|
||
var _this = this; | ||
>_this : Symbol(_this, Decl(accessorInferredReturnTypeErrorInReturnStatement.ts, 2, 7)) | ||
>this : Symbol(basePrototype, Decl(accessorInferredReturnTypeErrorInReturnStatement.ts, 0, 26)) | ||
|
||
return _this.collection.schema.primaryPath; | ||
>_this : Symbol(_this, Decl(accessorInferredReturnTypeErrorInReturnStatement.ts, 2, 7)) | ||
|
||
}, | ||
}; | ||
|
26 changes: 26 additions & 0 deletions
26
tests/baselines/reference/accessorInferredReturnTypeErrorInReturnStatement.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//// [tests/cases/compiler/accessorInferredReturnTypeErrorInReturnStatement.ts] //// | ||
|
||
=== accessorInferredReturnTypeErrorInReturnStatement.ts === | ||
export var basePrototype = { | ||
>basePrototype : { readonly primaryPath: any; } | ||
>{ get primaryPath() { var _this = this; return _this.collection.schema.primaryPath; }, } : { readonly primaryPath: any; } | ||
|
||
get primaryPath() { | ||
>primaryPath : any | ||
|
||
var _this = this; | ||
>_this : { readonly primaryPath: any; } | ||
>this : { readonly primaryPath: any; } | ||
|
||
return _this.collection.schema.primaryPath; | ||
>_this.collection.schema.primaryPath : any | ||
>_this.collection.schema : any | ||
>_this.collection : any | ||
>_this : { readonly primaryPath: any; } | ||
>collection : any | ||
>schema : any | ||
>primaryPath : any | ||
|
||
}, | ||
}; | ||
|
9 changes: 9 additions & 0 deletions
9
tests/cases/compiler/accessorInferredReturnTypeErrorInReturnStatement.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// @strict: true | ||
// @declaration: true | ||
|
||
export var basePrototype = { | ||
get primaryPath() { | ||
var _this = this; | ||
return _this.collection.schema.primaryPath; | ||
}, | ||
}; |