Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interactive type inlay hints #55141

Merged
merged 4 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading