-
Notifications
You must be signed in to change notification settings - Fork 0
TypeScript language server
Sergey Skorik edited this page Sep 11, 2018
·
10 revisions
- Create workspace from the Node stack with nodejs-hello-world project.
- Enable TypeScript language server in the Installers tab and start the workspace.
- Create “Greeter.ts” file with content:
import {Print} from './testPrint'
class Greeter {
greeting: string;
constructor(message: string) {
this.greeting = message;
}
greet() {
return "Hello, " + this.greeting;
}
testPrint(): void {
const printVar = new Print();
printVar.print("test print");
}
}
let greeter = new Greeter("world");
- Create "testPrint.ts" with content:
let name: string;
export class Print {
print (setVAlue: string): void
{
name = setVAlue;
console.log('<<:'+ name);
}
}
- Language server initialization
- From the project open "Greeter.ts" file.
- Check
Finished language servers initialization, file path '/nodejs-hello-world/Greeter.ts'
message in the dev-machine console.
- Autocomplete feature
- Open "Greeter.ts" file.
- Add empty line after the code and type
greeter.
. Sent Ctrl+Space. Make sure thatgreet
function andgreeting
field are present in the proposal panel. - Delete the added line.
- Find definition feature
- Open "Greeter.ts" file.
- Set cursor to 14:20 position and invoke Assistant -> Find Definition. The "testPrint.ts" file should be opened and print function should be selected.
- Close the "testPrint.ts" file. Repeat previous step using F4 key instead of Assistant -> Find Definition invocation.
- Code validation feature, Comment line
- Open "Greeter.ts" file.
- Move cursor in 3:2 position.
- Add space into keyword class like:
c lass
. Make sure that error markers have appeared. Click on first marker and check the message like:Cannot find name 'lass'.
. - Restore content. Error marker should disappear.
- Move cursor in line 1 position and comment this line by Ctrl+/ buttons.
- Check that text in line 1 was changed from
import {Print} from './testPrint'
to//import {Print} from './testPrint'
. - Uncomment this line by Ctrl+/ buttons.
- Format code feature
- Open "testPrint.ts" file.
- Start Format option from context menu;
- Check that the file content after formatting was changed to:
let name: string;
export class Print {
print(setVAlue: string): void {
name = setVAlue;
console.log('<<:' + name);
}
}
Rename
- Open "Greeter.ts" file.
- Select
printVar
variable. - Start Rename feature by Shift+F6 or from Assistant menu.
- Type new variable name.
- Check that the variable name was changed.
Find References
- Open "Greeter.ts" file.
- Move mouse pointer on position 4:12.
- Start Find References feature by pressing Alt+F7 buttons or from Assistant menu.
- Check that Find References panel is opened with
/nodejs-hello-world/Greeter.ts From:4:5 To:4:13
result in it.
Signature Help
- Open "Greeter.ts" file.
- Add empty line after the code and type
greeter.testPrint
. - Type '(' symbol and wait for hover popup with
testPrint(): void
text. - Delete added line.
Go To Symbol
- Open "Greeter.ts" file.
- Start Go To Symbol feature by Ctrl+F12 buttons or from Assistant menu.
- Wait for Go To Symbol form is opened with next lines:
"Greeter" symbols(9)
greeter
Greeter
constructor
greet
greeting
testPrint
printVar
Print
- Click on any of them and check that it correctly selected in file.
Find Project Symbol
- Open "Greeter.ts" file.
- Start Find Project Symbol feature by Alt+N buttons or from Assistant menu.
- Type
print
in Find Project Symbol form input. - Wait for
testPrint /nodejs-hello-world/Greeter.ts
line. - Click on it and check that it correctly selected in file.