-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Description
From @donaldpipowitch on May 4, 2016 6:16
- VSCode Version: 1.0.0
- OS Version: OS X 10.11.4
I think IntelliSense could show more documentation than it currently does. Take the following example (concrete feature requests are marked with a leading "❤️"):
/**
* Add numbers!
* @param a First number.
* @param b Second number.
*/
function add(a: number, b: number): number {
return a + b;
}
/**
* This is a.
*/
const a = 1;
const c = add(a, 2);
/**
* This is some object.
*/
interface SomeObject {
/**
* This is foo.
*/
foo: string;
/**
* This is bar.
*/
bar: string;
}
/*
* This is an instance of some object.
*/
const someObject: SomeObject = {
/**
* Test.
*/
foo: 'foo',
bar: 'bar'
};
const foo2 = someObject.foo;And now let us step through each statement and look if it could be improved.
1. Function signature
function add(a: number, b: number): number {- Hovering over
addshowsAdd numbers!. - Hovering over
ashowsFirst number.. - Hovering over
bshowsSecond number..
Great. Everything works 👍
2. Function body
return a + b;- Hovering over
ashowsFirst number.. - Hovering over
bshowsSecond number..
Great. Everything works 👍
3. Variable declaration
const a = 1;- Hovering over
ashowsThis is a..
Great. Everything works 👍
4. Function call
const c = add(a, 2);- Hovering over
cshows nothing.- This is expected. We have no description like for
const a. - ❓ However... it doesn't seem we can document return values from a function call properly. Adding
* @return This is the sum.to thefunction adddocumentation shows the return annotation as part of the description. But it would be nice, if hovering overcwould showThis is the sum.instead. - If we'd add a description to
const clike we did forconst a(e.g.This is c.) and we add a proper@returnannotation tofunction addit would be nice if IntelliSense would show both description when hovering overc:This is c.andThis is the sum.(maybe with a small visual delimiter between both descriptions.).
- This is expected. We have no description like for
- Hovering over
addshowsAdd numbers!. - Hovering over
ashowsThis is a..- It would be nice, if it would also show
First number..
- It would be nice, if it would also show
- Hovering over
2shows nothing.- It would be nice, if it would show
Second number..
- It would be nice, if it would show
❤️ Request 1: It would be nice to show @return annotations correctly in IntelliSense.
❤️ Request 2: It would be nice to additionally show @param and @return annotations alongside with descriptions of variable declarations or at least as a fallback, if a variable has no own description.
5. Interface
interface SomeObject {- Hovering over
SomeObjectshowsThis is some object..
Great. Everything works 👍
6. Property in interface
foo: string;- Hovering over
fooshowsThis is foo..
Great. Everything works 👍
7. Object with interface
const someObject: SomeObject = {- Hovering over
someObjectshows nothing.- I'd expect to see
This is an instance of some object..
- I'd expect to see
- Hovering over
SomeObjectshowsThis is some object..
❤️ Request 3: It would be nice to show the description of an object using an interface.
8. Properties of an object with interface
foo: 'foo',
bar: 'bar'- Hovering over
fooshowsTest..- It could also show
This is foo..
- It could also show
- Hovering over
barshows nothing.- It could at least show
This is bar..
- It could at least show
❤️ Request 4: It would be nice to additionally show property descriptions from an interface and descriptions of properties in a concrete object or at least as a fallback, if the property of an object has no own description.
9. Using properties of an object with interface
const foo2 = someObject.foo;- Hovering over
fooshowsThis is foo..- It could also show
Test.. (💡 This was very surprising for me that IntelliSense usedThis is foo.instead ofTest.here. However... best thing would be to show both.)
- It could also show
- Hovering over
foo2shows nothing.- It looks like the the type is correctly inferred and it would be nice if the descriptions could be reused here, too. (E.g.
Test.andThis is foo.)
- It looks like the the type is correctly inferred and it would be nice if the descriptions could be reused here, too. (E.g.
- Hovering over
someObjectshows nothing.- It should show
This is an instance of some object.(and could additionally showThis is some object.).
- It should show
❤️ Request 5: When using properties of an object which are documented in the object itself and in the interface it would be nice if the description from the object declaration could be shown (because it is probably more custom to the current use case) or show both descriptions.
❤️ Request 6: When types can be inferred it would be nice to infer descriptions, too.
Copied from original issue: microsoft/vscode#6083