microsoft / typescript-sublime-plugin Goto Github PK
View Code? Open in Web Editor NEWIO wrapper around TypeScript language services, allowing for easy consumption by editor plugins
License: Apache License 2.0
IO wrapper around TypeScript language services, allowing for easy consumption by editor plugins
License: Apache License 2.0
var map:
This gives the correct error ("Type expected"), but has no span if it is at the end of the file. In cases like these, VS uses the last character of the file as the span. That way the user sees that there is an error.
I've only managed to repro this on a F12 code file. I put it up at \bptfs1\public\roblou\tsss\selfTestPageUI.ts. There are lots of errors here for missing things but it also reproes in the actual source directory.
Find onKeyDown, highlight Event, type KeyboardEvent. I get something different every time depending on whether I type the full string myself or use autocomplete.
This is ST3 on PC.
[found by Will Anderson]
interface ITest {
foo(): number;
}
class Sub implements ITest {
constructor() {
}
}
Sub will show a squiggly but when clicked on it the error doesn't show up in the status bar. The output window show this exception:
{"command": "quickinfo", "type": "request", "arguments": {"line": 7, "col": 9, "file": "E:\tls\samples\test.ts"}, "seq": 1970}
Traceback (most recent call last):
File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 549, in run_
return self.run(edit)
File "C:\Users\hania\AppData\Roaming\Sublime Text 3\Packages\TypeScript\TypeScript.py", line 841, in run
self.view.set_status("typescript_error", errorText)
File "C:\Program Files\Sublime Text 3\sublime.py", line 887, in set_status
sublime_api.view_set_status(self.view_id, key, value)
TypeError: String required
Not sure what SaveTmp is supposed to do, but it does not save the file.
var test = false
;
(semicolon)A semicolon appears instantly.
Long (2-5 second) period of time where ST3 appears frozen and doesn't respond to keypresses. Semicolon (and all other keys pressed) appear after lag.
Open checker.ts, and navigate to the line
globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol");
Change it to the following:
globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", 0);
This new code is wrong, but it takes a very long time (at least 20 seconds) for an error to appear.
Then remove the extra argument, and the error also lingers for a very long time.
AlecG used the portable version of sublime instead of the msi. The plugin doesn't work in this scenario.
That would allow for a nice formatting in the UI and makes the overall API more consistence.
The current documentation list examples, but without a definition clients can't know about the set of valid kinds and kindModifiers.
Currently requests are a simple string and the responses use JSON. It should be supported to make the request using JSON as well and to correlate the request with a response. Each request should have a response.
if (true) {
}
var x = 'hello';
Copy the last line to the clipboard, and paste it inside the if block.
Expected: var statement gets indented
Actual: does not get indented
VS has this functionality.
This one might be a bit of a stretch goal.
var [r, g, b] = [0xFF, 0xFF, 0xFF];
var displayStr = `[Red ${ r }, Green: ${ g }, Blue: ${ b }]`
The following should be colorized appropriately:
}, Green: ${
}, Blue: ${
For resources relating to template strings, see:
class NewClass {
<ENTER>
keyclass NewClass {
<TAB><CURSOR HERE>
}
class NewClass {
<CURSOR HERE>}
Build - Pulled from TypeScript-Service Master branch at 2/19, 3:00pm
Platform - Sublime Text 3 on PC
See attached for repro project (rename from .png to .zip to unzip my project)
I have two files, cat.ts that defined "Cat" class, and dog.ts that ///ref cat.ts, and creates multiple "Cat" objects. In dog.ts, go to a "Cat" and do a rename to "AwesomeCat". Notice that only "Cat"s in dog.ts gets renamed, cat.ts still has "Cat". Also, I noticed that in dog.ts", the class that was defined as "Dog" got renamed to be "AwesomeCat" - it should have been left alone as "Dog".
Go-to-def is Ctrl+T
,Ctrl+D
. Go to declaration doesn't even have a well-defined concept in our language. Let's just make the two equivalent.
Never mind, it seems that the keybinding is go-to-defintion, but it is not working correctly.
From parser.ts
module ts {
var nodeConstructors = new Array<new () => Node>(SyntaxKind.Count);
/* @internal */ export var parseTime = 0;
export function getNodeConstructor(kind: SyntaxKind): new () => Node {
return nodeConstructors[kind] || (nodeConstructors[kind] = objectAllocator.getNodeConstructor(kind));
}
If you try F12 on Node
, it will only work if types.ts
is open.
If you try F12 on nodeConstructors
, kind
, SyntaxKind
, or objectAllocator
, nothing happens (e.g."Unable to find nodeConstructors"), even if types.ts
is open.
If you try F12 on getNodeConstructor
of objectAllocator.getNodeConstructor
, it takes you to the wrong place (i.e. it takes you to the above function definition, instead of ObjectAllocator
in core.ts
Keep in mind, Ctrl+T, Ctrl+D
works for all of these
Users cannot press the tab key. It doesn't do anything in the editor.
Using Sublime 3 & 2
interface Name {
nameId: string;
}
interface Data {
contents: {};
}
var map;
static C; // error on this line
The compiler gives the error:
"Expression expected"
Sublime gives the error:
"Declaration or statement expected"
I've just installed the plugin on the mac by cloning this repo into the Packages folder. I opened checker.ts, and colorization and completion are working, but nothing else is.
When I open the console, I keep seeing the quickinfo command coming through, but it results in a broken pipe error:
{"command": "quickinfo", "arguments": {"line": 197, "col": 38, "file": "/Users/jfreeman/ts/src/compiler/checker.ts"}, "type": "request", "seq": 311}
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 549, in run_
return self.run(edit)
File "/Users/jfreeman/Library/Application Support/Sublime Text 3/Packages/TypeScript.py", line 787, in run
cli.service.quickInfo(self.view.file_name(), getLocationFromView(self.view), self.handleQuickInfo)
File "/Users/jfreeman/Library/Application Support/Sublime Text 3/Packages/libs/serviceproxy.py", line 95, in quickInfo
self.__comm.sendCmd(onCompletedJson, jsonStr, req.seq)
File "/Users/jfreeman/Library/Application Support/Sublime Text 3/Packages/libs/nodeclient.py", line 85, in sendCmd
self.postCmd(cmd)
File "/Users/jfreeman/Library/Application Support/Sublime Text 3/Packages/libs/nodeclient.py", line 121, in postCmd
self.__serverProc.stdin.write(cmd.encode())
BrokenPipeError: [Errno 32] Broken pipe
And when I make an edit, I get:
{"command": "change", "arguments": {"line": 198, "file": "/Users/jfreeman/ts/src/compiler/checker.ts", "endLine": 198, "insertString": "", "col": 27, "endCol": 28}, "type": "request", "seq": 371}
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 374, in on_text_command
res = callback.on_text_command(v, name, args)
File "/Users/jfreeman/Library/Application Support/Sublime Text 3/Packages/TypeScript.py", line 589, in on_text_command
sendReplaceChangesForRegions(view, self.expandEmptyLeft(view.sel()), "")
File "/Users/jfreeman/Library/Application Support/Sublime Text 3/Packages/TypeScript.py", line 358, in sendReplaceChangesForRegions
cli.service.change(view.file_name(), location, endLocation, insertString)
File "/Users/jfreeman/Library/Application Support/Sublime Text 3/Packages/libs/serviceproxy.py", line 23, in change
self.__comm.postCmd(jsonStr)
File "/Users/jfreeman/Library/Application Support/Sublime Text 3/Packages/libs/nodeclient.py", line 121, in postCmd
self.__serverProc.stdin.write(cmd.encode())
BrokenPipeError: [Errno 32] Broken pipe
Currently the service dies and exits when there is an exception. The service should try to recover and log the exception.
Make a new file in sublime text 3 and paste this into the editor:
export class Foo {
}
export class Bar extends Foo {
}
You will see a squiggly under Foo because we are exporting a class in a non-module. However, you will not see a squiggly under Bar.
Expected: Squigglies under both Foo and Bar.
Type the following:
C
As expected, you get an error on C: "Cannot find name C".
Now insert the word "static" before "C".
Expected: New error "Declaration or statement expected" on the word "static".
Actual: Status bar still shows old message with old span.
Make a new file and paste this into sublime text 3:
import blah = require("blah");
export class Foo {
}
You will see red squigglies under the import statement with the error "Cannot compile external modules unless the '--module' flag is provided.
If I have
declare function foo(s: string);
declare function foo(n: number);
foo(
It is very helpful to see the signatures of foo. Though I'm not sure whether it is better to use the completion list UI or the status bar.
Pressing F12 on a symbol, when there is a .ts and a .js file, takes you to the js instead of the ts.
Expected: Go to definition takes me to the typescript file, just as if I pressed ctrl + t, ctrl + d.
Actual: It takes me to the .js file.
interface Map<K, V> {
values(): IterableIterator<V>;
[Symbol.iterator]():IterableIterator<[K,V]>; // these angle brackets
}
The angle brackets around the V after values are colored a certain way to indicate type arguments, but the coloring around [K,V] are not the same color.
var functionName = "hello world";
function
is blue, Name
is white.
Hit Ctrl+Shift+P
; Ctrl+R
is not actually documented, which is useful even though it is a Sublime shortcut override.
Build - Pulled from TypeScript-Service Master branch at 2/19, 3:00pm
Platform - Sublime Text 3 on PC
See attached for repro project (rename from .png to .zip to unzip my project)
I have a file "dog.ts" that defines a class "Dog". I have a file called "cat.ts" that does not ///ref "dog.ts", yet it tries to create a "Dog" object (which rightfully results in a squiggle. In my "dog.ts" class, I then rename "Dog" to "AwesomeDog". For some reasons a "AwesomeDog" is then added to the bottom of my dog.ts file.
When the cursor resides on a word, it would be helpful to populate appropriate regions.
Looks like add_regions
might be the relevant API, with sublime.DRAW_NO_FILL
for now.
Consider the Roslyn timeouts:
Steps to reproduce (Sublime Text 3):
Expected: Sublime navigates to the line you clicked on.
Actual: Nothing happens.
/[/']{2}/.test("/'")
You don't have to escape a slash in square brackets, but things are colored as if that slash was the end of the regex, and the '
was the start of a string. VS handles this.
In the output window, we are getting module not found error for jsonhelpers.
Seems like sublime is loading all the py files in the current folder. The solution would be to move the library files to a sub folder.
[Found by AlecG]
The auto-complete is fantastic, but the one major thing missing is help filling in arguments. Right now, after I press enter to insert a function name, I immediate go to definition on the function to see its arguments. Then I go back and try to fill them in. And this gets tedious if the argument is a complex type with lots of constructor arguments.
It would be really great if you could display these to the user after they auto-complete a function name.
In the edit menu, there is a toggle comment command, but it does not do anything. I would expect it to put //
before all the lines in my selection. There is toggle block comment as well.
repro:
create two files:
ref.ts, contains:
function myAdd(a, b) {
return a + b;
}
test.ts, contains:
/// < reference path="ref.ts" / >
myAdd(1, 2);
Now remove the /// < refern.. line
remove myAdd(1, 2)
try to type myAdd and you get completions on it even if the ref.ts file is closed in the editor
interface I { }
var s: I;
s;
I would expect GoToType on s
to take me to the definition of I
, but it doesn't seem to do anything.
The service ends in an exception:
Err 49 Exception on executing command {"seq":108,"type":"request","command":"quickinfo","arguments":{"file":"P:/Playgrounds/sample-mankala/Position.ts","line":2,"col":24}}:
No Content.
Error: No Content.
at Errors (P:\BPT_Projects\Monaco\client\vs\languages\typescript\service\lib\tsserver.js:31147:32)
at ts.server.ts.server (P:\BPT_Projects\Monaco\client\vs\languages\typescript\service\lib\tsserver.js:31148:11)
at ts (P:\BPT_Projects\Monaco\client\vs\languages\typescript\service\lib\tsserver.js:31746:7)
at Object. (P:\BPT_Projects\Monaco\client\vs\languages\typescript\service\lib\tsserver.js:31747:3)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
I keep expecting page up/down to work in the intellisense menu because it can be very long. Instead it closes the menu and does page up/down on the document. This would just be nice to have.
if I type
interface I {
It completes to
interface I {}
by inserting the close brace.
However, if I now type the close brace myself, it inserts another one, rather than overtyping the inserted one.
interface I { }}
In ref.ts have some class
in test.ts have some class that extends the class in ref.ts
close ref.ts from the editor.
Delete (or rename) ref.ts in the file system.
type anything in test.ts and the reference tag at the top doesn't show as error. You can even still reference the members in the parent class.
Expected, it should show few errors in test.ts since ref.ts was gone.
Sublime supports full word selection upon double clicking. As of today, some change seems to have broken this behavior across all file types.
Currently requests are a simple string and the responses use JSON. It should be supported to make the request using JSON as well and to correlate the request with a response. Each request should have a response.
Enabling vintage mode. Then inside non-insert mode - press enter to select references. When jumping to the location, the mode is then switched to insert
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.