Skip to content

Commit

Permalink
Interactive type inlay hints (microsoft#55141)
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaSolOs authored and snovader committed Sep 23, 2023
1 parent 45bf165 commit 7f455f5
Show file tree
Hide file tree
Showing 28 changed files with 1,130 additions and 32 deletions.
356 changes: 343 additions & 13 deletions src/services/inlayHints.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ foo2((a) => { })
foo3(a => {
^
{
"text": ": (c: (d: 2 | 3) => void) => ...",
"text": ": (c: (d: 2 | 3) => void) => void",
"position": 331,
"kind": "Type",
"whitespaceBefore": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ foo(1);
"start": 14,
"length": 1
},
"file": "/tests/cases/fourslash/inlayHintsInterativeAnyParameter1.ts"
"file": "/tests/cases/fourslash/inlayHintsInteractiveAnyParameter1.ts"
},
{
"text": ":"
Expand All @@ -34,7 +34,7 @@ foo('');
"start": 14,
"length": 1
},
"file": "/tests/cases/fourslash/inlayHintsInterativeAnyParameter1.ts"
"file": "/tests/cases/fourslash/inlayHintsInteractiveAnyParameter1.ts"
},
{
"text": ":"
Expand All @@ -56,7 +56,7 @@ foo(true);
"start": 14,
"length": 1
},
"file": "/tests/cases/fourslash/inlayHintsInterativeAnyParameter1.ts"
"file": "/tests/cases/fourslash/inlayHintsInteractiveAnyParameter1.ts"
},
{
"text": ":"
Expand All @@ -78,7 +78,7 @@ foo((1));
"start": 14,
"length": 1
},
"file": "/tests/cases/fourslash/inlayHintsInterativeAnyParameter1.ts"
"file": "/tests/cases/fourslash/inlayHintsInteractiveAnyParameter1.ts"
},
{
"text": ":"
Expand All @@ -100,7 +100,7 @@ foo(foo(1));
"start": 14,
"length": 1
},
"file": "/tests/cases/fourslash/inlayHintsInterativeAnyParameter1.ts"
"file": "/tests/cases/fourslash/inlayHintsInteractiveAnyParameter1.ts"
},
{
"text": ":"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ foo(1);
"start": 14,
"length": 1
},
"file": "/tests/cases/fourslash/inlayHintsInterativeAnyParameter2.ts"
"file": "/tests/cases/fourslash/inlayHintsInteractiveAnyParameter2.ts"
},
{
"text": ":"
Expand All @@ -34,7 +34,7 @@ foo('');
"start": 14,
"length": 1
},
"file": "/tests/cases/fourslash/inlayHintsInterativeAnyParameter2.ts"
"file": "/tests/cases/fourslash/inlayHintsInteractiveAnyParameter2.ts"
},
{
"text": ":"
Expand All @@ -56,7 +56,7 @@ foo(true);
"start": 14,
"length": 1
},
"file": "/tests/cases/fourslash/inlayHintsInterativeAnyParameter2.ts"
"file": "/tests/cases/fourslash/inlayHintsInteractiveAnyParameter2.ts"
},
{
"text": ":"
Expand All @@ -78,7 +78,7 @@ foo(() => 1);
"start": 14,
"length": 1
},
"file": "/tests/cases/fourslash/inlayHintsInterativeAnyParameter2.ts"
"file": "/tests/cases/fourslash/inlayHintsInteractiveAnyParameter2.ts"
},
{
"text": ":"
Expand All @@ -100,7 +100,7 @@ foo(function () { return 1 });
"start": 14,
"length": 1
},
"file": "/tests/cases/fourslash/inlayHintsInterativeAnyParameter2.ts"
"file": "/tests/cases/fourslash/inlayHintsInteractiveAnyParameter2.ts"
},
{
"text": ":"
Expand All @@ -122,7 +122,7 @@ foo({});
"start": 14,
"length": 1
},
"file": "/tests/cases/fourslash/inlayHintsInterativeAnyParameter2.ts"
"file": "/tests/cases/fourslash/inlayHintsInteractiveAnyParameter2.ts"
},
{
"text": ":"
Expand All @@ -144,7 +144,7 @@ foo({ a: 1 });
"start": 14,
"length": 1
},
"file": "/tests/cases/fourslash/inlayHintsInterativeAnyParameter2.ts"
"file": "/tests/cases/fourslash/inlayHintsInteractiveAnyParameter2.ts"
},
{
"text": ":"
Expand All @@ -166,7 +166,7 @@ foo([]);
"start": 14,
"length": 1
},
"file": "/tests/cases/fourslash/inlayHintsInterativeAnyParameter2.ts"
"file": "/tests/cases/fourslash/inlayHintsInteractiveAnyParameter2.ts"
},
{
"text": ":"
Expand All @@ -188,7 +188,7 @@ foo([1]);
"start": 14,
"length": 1
},
"file": "/tests/cases/fourslash/inlayHintsInterativeAnyParameter2.ts"
"file": "/tests/cases/fourslash/inlayHintsInteractiveAnyParameter2.ts"
},
{
"text": ":"
Expand All @@ -210,7 +210,7 @@ foo(foo);
"start": 14,
"length": 1
},
"file": "/tests/cases/fourslash/inlayHintsInterativeAnyParameter2.ts"
"file": "/tests/cases/fourslash/inlayHintsInteractiveAnyParameter2.ts"
},
{
"text": ":"
Expand All @@ -232,7 +232,7 @@ foo((1));
"start": 14,
"length": 1
},
"file": "/tests/cases/fourslash/inlayHintsInterativeAnyParameter2.ts"
"file": "/tests/cases/fourslash/inlayHintsInteractiveAnyParameter2.ts"
},
{
"text": ":"
Expand All @@ -254,7 +254,7 @@ foo(foo(1));
"start": 14,
"length": 1
},
"file": "/tests/cases/fourslash/inlayHintsInterativeAnyParameter2.ts"
"file": "/tests/cases/fourslash/inlayHintsInteractiveAnyParameter2.ts"
},
{
"text": ":"
Expand All @@ -276,7 +276,7 @@ foo(foo(1));
"start": 14,
"length": 1
},
"file": "/tests/cases/fourslash/inlayHintsInterativeAnyParameter2.ts"
"file": "/tests/cases/fourslash/inlayHintsInteractiveAnyParameter2.ts"
},
{
"text": ":"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
const f1: F1 = (a, b) => { }
^
{
"text": ": string",
"position": 58,
"kind": "Type",
"whitespaceBefore": true
}

const f1: F1 = (a, b) => { }
^
{
"text": ": number",
"position": 61,
"kind": "Type",
"whitespaceBefore": true
}

const f2: F1 = (a, b: number) => { }
^
{
"text": ": string",
"position": 87,
"kind": "Type",
"whitespaceBefore": true
}

foo1((a) => { })
^
{
"text": ": string",
"position": 157,
"kind": "Type",
"whitespaceBefore": true
}

foo2((a) => { })
^
{
"text": ": 2 | 3",
"position": 232,
"kind": "Type",
"whitespaceBefore": true
}

foo3(a => {
^
{
"text": ": (c: (d: 2 | 3) => void) => void",
"position": 331,
"kind": "Type",
"whitespaceBefore": true
}

a(d => {})
^
{
"text": ": 2 | 3",
"position": 344,
"kind": "Type",
"whitespaceBefore": true
}

foo4(1, a => { })
^
{
"text": ": number",
"position": 409,
"kind": "Type",
"whitespaceBefore": true
}

const foo5: F2 = (a) => { }
^
{
"text": ": { a: number; b: string; }",
"position": 492,
"kind": "Type",
"whitespaceBefore": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
=== No inlay hints ===
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
bar: function (x?): void {
^
{
"text": ": boolean",
"position": 87,
"kind": "Type",
"whitespaceBefore": true
}

set foo(value) { this.#value = value; }
^
{
"text": ": number",
"position": 250,
"kind": "Type",
"whitespaceBefore": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
=== No inlay hints ===
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
=== No inlay hints ===
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
function bar () { return require('./a').a; }
^
{
"text": "",
"displayParts": [
{
"text": ": "
},
{
"text": "1"
}
],
"position": 58,
"kind": "Type",
"whitespaceBefore": true
}

const d = bar()
^
{
"text": "",
"displayParts": [
{
"text": ": "
},
{
"text": "1"
}
],
"position": 111,
"kind": "Type",
"whitespaceBefore": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
y.foo(1, 2)
^
{
"text": "",
"position": 88,
"kind": "Parameter",
"whitespaceAfter": true,
"displayParts": [
{
"text": "a",
"span": {
"start": 40,
"length": 1
},
"file": "/a.js"
},
{
"text": ":"
}
]
}

y.foo(1, 2)
^
{
"text": "",
"position": 91,
"kind": "Parameter",
"whitespaceAfter": true,
"displayParts": [
{
"text": "b",
"span": {
"start": 51,
"length": 1
},
"file": "/a.js"
},
{
"text": ":"
}
]
}
Loading

0 comments on commit 7f455f5

Please sign in to comment.