mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Avoid provide hints for binding patterns (#44961)
* Avoid provide hints for binding patterns * Rename as 56
This commit is contained in:
parent
0f6e6efde0
commit
8cdcec4454
@ -121,8 +121,12 @@ namespace ts.InlayHints {
|
||||
}
|
||||
|
||||
function visitVariableLikeDeclaration(decl: VariableDeclaration | PropertyDeclaration) {
|
||||
if (!decl.initializer || isBindingPattern(decl.name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const effectiveTypeAnnotation = getEffectiveTypeAnnotationNode(decl);
|
||||
if (effectiveTypeAnnotation || !decl.initializer) {
|
||||
if (effectiveTypeAnnotation) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
40
tests/cases/fourslash/inlayHintsShouldWork56.ts
Normal file
40
tests/cases/fourslash/inlayHintsShouldWork56.ts
Normal file
@ -0,0 +1,40 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//// const object/*a*/ = { foo: 1, bar: 2 }
|
||||
//// const array/*b*/ = [1, 2]
|
||||
//// const a/*c*/ = object;
|
||||
//// const { foo, bar } = object;
|
||||
//// const {} = object;
|
||||
//// const b/*d*/ = array;
|
||||
//// const [ first, second ] = array;
|
||||
//// const [] = array;
|
||||
|
||||
const markers = test.markers();
|
||||
verify.getInlayHints([
|
||||
{
|
||||
text: ': { foo: number; bar: number; }',
|
||||
position: markers[0].position,
|
||||
kind: ts.InlayHintKind.Type,
|
||||
whitespaceBefore: true
|
||||
},
|
||||
{
|
||||
text: ': number[]',
|
||||
position: markers[1].position,
|
||||
kind: ts.InlayHintKind.Type,
|
||||
whitespaceBefore: true
|
||||
},
|
||||
{
|
||||
text: ': { foo: number; bar: number; }',
|
||||
position: markers[2].position,
|
||||
kind: ts.InlayHintKind.Type,
|
||||
whitespaceBefore: true
|
||||
},
|
||||
{
|
||||
text: ': number[]',
|
||||
position: markers[3].position,
|
||||
kind: ts.InlayHintKind.Type,
|
||||
whitespaceBefore: true
|
||||
}
|
||||
], undefined, {
|
||||
includeInlayVariableTypeHints: true
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user