clausreinke / typescript-tools

(repo no longer active) Tools related to the TypeScript language
Apache License 2.0
266 stars 29 forks source link

Can't get completions to work #3

Closed zlumer closed 11 years ago

zlumer commented 11 years ago

Hello

I tried using TSS a couple times and can't get completion to work. All the type or definition searches are correct, but I get an empty array for completions. Source file content:

var s:string = ""; s.

(it doesn't work with line breaks too, I removed them only for easier testing)

Look at the output below:

C:\dev\TS>node external\typescript-tools.git\bin\tss.js src\competion.ts
"loaded C:/dev/TS/src/competion.ts, TSS listening.."
>
"TSS command syntax error: "
type 1 22 C:/dev/TS/src/competion.ts
"TSS command processing error: TypeError: Cannot read property 'memberName' of null"
> type 1 21 C:/dev/TS/src/competion.ts
"string"
> definition 1 21 C:/dev/TS/src/competion.ts
{"def":{"unitIndex":1,"minChar":0,"limChar":18,"kind":"variable","name":"s","co
ntainerKind":"","containerName":"__GLO"},"file":"C:/dev/TS/src/competion.ts","m
in":[1,1],"lim":[1,19]}
> completions true 1 21 C:/dev/TS/src/competion.ts
{"maybeInaccurate":false,"isMemberCompletion":true,"entries":[]}
> completions true 1 22 C:/dev/TS/src/competion.ts
{"maybeInaccurate":false,"isMemberCompletion":true,"entries":[]}
> completions false 1 22 C:/dev/TS/src/competion.ts
{"maybeInaccurate":false,"isMemberCompletion":false,"entries":[{"name":"void","
type":"void","kind":"keyword","kindModifiers":""},{"name":"bool","type":"bool",
"kind":"keyword","kindModifiers":""},{"name":"number","type":"number","kind":"k
eyword","kindModifiers":""},{"name":"string","type":"string","kind":"keyword","
kindModifiers":""},{"name":"any","type":"any","kind":"keyword","kindModifiers":
""},{"name":"null","type":"any","kind":"keyword","kindModifiers":""},{"name":"u
ndefined","type":"undefined","kind":"keyword","kindModifiers":""},{"name":"s","
type":"string","kind":"variable","kindModifiers":""}]}
quit
"TSS closing"

C:\dev\TS>

As you can see, I get a correct definition or type result, but member completion is empty.

Do you know what the problem can be? And maybe you can reproduce this error, too.

Thanks.

clausreinke commented 11 years ago

Thanks for the detailed report. That looks as if the lib.d.ts file isn't found, so the string properties are unknown.

Try editing the file typescript-tools/bin/defaultLibs.d.ts to point the reference path to your TypeScript installation's lib.d.ts. Then completion should work.

zlumer commented 11 years ago

Thanks for the quick and helpful answer! I added the reference to the beginning of the file and now everything works:

///<reference path='../external/typescript/bin/lib.d.ts'/>
var s:string = ""; s.
C:\dev\TS>node external\typescript-tools.git\bin\tss.js src\competion.ts
"loaded C:/dev/TS/src/competion.ts, TSS listening.."
completions true 2 21 C:/dev/TS/src/competion.ts
{"maybeInaccurate":false,"isMemberCompletion":true,"entries":[{"name":"toString","type":"() => string","kind":"method","kindModifiers":"declare,public
"},{"name":"charAt","type":"(pos: number) => string","kind":"method","kindModifiers":"declare,public"},{"name":"charCodeAt","type":"(index: number) =>
 number","kind":"method","kindModifiers":"declare,public"},{"name":"concat","type":"(...strings: string[]) => string","kind":"method","kindModifiers":
"declare,public"},{"name":"indexOf","type":"(searchString: string, position?: number) => number","kind":"method","kindModifiers":"declare,public"},{"n
ame":"lastIndexOf","type":"(searchString: string, position?: number) => number","kind":"method","kindModifiers":"declare,public"},{"name":"localeCompa
re","type":"(that: string) => number","kind":"method","kindModifiers":"declare,public"},{"name":"match","type":"{ (regexp: string): string[]; (regexp:
 RegExp): string[]; }","kind":"method","kindModifiers":"declare,public"},{"name":"replace","type":"{ (searchValue: string, replaceValue: string): stri
ng; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (
searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; }","kind":"method","kindModifiers":"declare,public"},{"name
":"search","type":"{ (regexp: string): number; (regexp: RegExp): number; }","kind":"method","kindModifiers":"declare,public"},{"name":"slice","type":"
(start: number, end?: number) => string","kind":"method","kindModifiers":"declare,public"},{"name":"split","type":"{ (seperator: string, limit?: numbe
r): string[]; (seperator: RegExp, limit?: number): string[]; }","kind":"method","kindModifiers":"declare,public"},{"name":"substring","type":"(start:
number, end?: number) => string","kind":"method","kindModifiers":"declare,public"},{"name":"toLowerCase","type":"() => string","kind":"method","kindMo
difiers":"declare,public"},{"name":"toLocaleLowerCase","type":"() => string","kind":"method","kindModifiers":"declare,public"},{"name":"toUpperCase","
type":"() => string","kind":"method","kindModifiers":"declare,public"},{"name":"toLocaleUpperCase","type":"() => string","kind":"method","kindModifier
s":"declare,public"},{"name":"trim","type":"() => string","kind":"method","kindModifiers":"declare,public"},{"name":"substr","type":"(from: number, le
ngth?: number) => string","kind":"method","kindModifiers":"declare,public"},{"name":"length","type":"number","kind":"property","kindModifiers":"public
"}]}