mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 12:32:08 -06:00
fix(57445): No inlay hints for property declaration types inferred from constructor (#57494)
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
This commit is contained in:
parent
47a800f5a4
commit
884d649846
@ -118,6 +118,7 @@ import {
|
||||
tokenToString,
|
||||
TupleTypeReference,
|
||||
Type,
|
||||
TypeFlags,
|
||||
unescapeLeadingUnderscores,
|
||||
UserPreferences,
|
||||
usingSingleLineStringWriter,
|
||||
@ -260,7 +261,10 @@ export function provideInlayHints(context: InlayHintsContext): InlayHint[] {
|
||||
}
|
||||
|
||||
function visitVariableLikeDeclaration(decl: VariableDeclaration | PropertyDeclaration) {
|
||||
if (!decl.initializer || isBindingPattern(decl.name) || isVariableDeclaration(decl) && !isHintableDeclaration(decl)) {
|
||||
if (
|
||||
decl.initializer === undefined && !(isPropertyDeclaration(decl) && !(checker.getTypeAtLocation(decl).flags & TypeFlags.Any)) ||
|
||||
isBindingPattern(decl.name) || (isVariableDeclaration(decl) && !isHintableDeclaration(decl))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -6,4 +6,13 @@
|
||||
"position": 15,
|
||||
"kind": "Type",
|
||||
"whitespaceBefore": true
|
||||
}
|
||||
|
||||
d;
|
||||
^
|
||||
{
|
||||
"text": ": number | null",
|
||||
"position": 50,
|
||||
"kind": "Type",
|
||||
"whitespaceBefore": true
|
||||
}
|
||||
@ -1,9 +1,18 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @strict: true
|
||||
//// class C {
|
||||
//// a = 1
|
||||
//// b: number = 2
|
||||
//// c;
|
||||
//// d;
|
||||
////
|
||||
//// constructor(value: number) {
|
||||
//// this.d = value;
|
||||
//// if (value <= 0) {
|
||||
//// this.d = null;
|
||||
//// }
|
||||
//// }
|
||||
//// }
|
||||
|
||||
verify.baselineInlayHints(undefined, {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user