typescript-ruby/typescript-node-ruby

Having trouble getting the jquery.d.ts reference to compile

agmcleod opened this issue · 11 comments

Hello. Using the rails gem more specfically, but i can't seem to get the jquery.d.ts to compile in rails. The same file with my environment compiles fine using tsc directly. I get a long stack trace in the rails log that looks like this:

/var/folders/3h/p20v585s2fb5wg6rk4ldgxxrf2r83c/T/typescript-node20150421-2010-1kbyyo8.ts(2679,36): error TS1005: ',' expected.
/var/folders/3h/p20v585s2fb5wg6rk4ldgxxrf2r83c/T/typescript-node20150421-2010-1kbyyo8.ts(2690,22): error TS1005: ',' expected.
/var/folders/3h/p20v585s2fb5wg6rk4ldgxxrf2r83c/T/typescript-node20150421-2010-1kbyyo8.ts(2690,29): error TS1005: ',' expected.
/var/folders/3h/p20v585s2fb5wg6rk4ldgxxrf2r83c/T/typescript-node20150421-2010-1kbyyo8.ts(2713,33): error TS1005: ',' expected.
/var/folders/3h/p20v585s2fb5wg6rk4ldgxxrf2r83c/T/typescript-node20150421-2010-1kbyyo8.ts(2713,41): error TS1005: ',' expected.
/var/folders/3h/p20v585s2fb5wg6rk4ldgxxrf2r83c/T/typescript-node20150421-2010-1kbyyo8.ts(2719,41): error TS1005: ',' expected.
/var/folders/3h/p20v585s2fb5wg6rk4ldgxxrf2r83c/T/typescript-node20150421-2010-1kbyyo8.ts(2726,36): error TS1005: ',' expected.
/var/folders/3h/p20v585s2fb5wg6rk4ldgxxrf2r83c/T/typescript-node20150421-2010-1kbyyo8.ts(2726,44): error TS1005: ',' expected.
/var/folders/3h/p20v585s2fb5wg6rk4ldgxxrf2r83c/T/typescript-node20150421-2010-1kbyyo8.ts(2734,38): error TS1005: ',' expected.
/var/folders/3h/p20v585s2fb5wg6rk4ldgxxrf2r83c/T/typescript-node20150421-2010-1kbyyo8.ts(2734,46): error TS1005: ',' expected.
/var/folders/3h/p20v585s2fb5wg6rk4ldgxxrf2r83c/T/typescript-node20150421-2010-1kbyyo8.ts(2769,27): error TS1005: ',' expected.
/var/folders/3h/p20v585s2fb5wg6rk4ldgxxrf2r83c/T/typescript-node20150421-2010-1kbyyo8.ts(2769,34): error TS1005: ',' expected.

  (in /Users/aaron.mcleod/Sites/typescripttest/app/assets/javascripts/ts/jquery.d.ts)

Do i need to tell the gem to use a specific version that's installed or something?

+1 on this.

I'm getting, however:

ActionView::Template::Error (/var/folders/x_/chd9rmv54_l45r_n5nt99bk80000gn/T/typescript-node20150422-4356-1szg4pu.ts(15,1): error TS2095: Could not find symbol 'angular'.

Which is strange because I'm properly referencing angular.

I got it to work using angular.d.ts and jquery.d.t.s from the 1.3.0 branch of DefinitelyTyped.

Interesting. I did the same, getting a new error:

/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:906
                        vector.release();
                               ^
TypeError: undefined is not a function
    at BitMatrixImpl.release (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:906:32)
    at PullInstantiatedTypeReferenceSymbol.PullTypeSymbol.wrapsSomeTypeParameterIntoInfinitelyExpandingTypeReference (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:38021:26)
    at PullInstantiatedTypeReferenceSymbol.getGenerativeTypeClassification (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:56587:30)
    at PullTypeEnclosingTypeWalker.getGenerativeClassification (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:38846:36)
    at PullTypeResolutionContext.oneOfClassificationsIsInfinitelyExpanding (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:39598:71)
    at PullTypeResolver.sourceIsRelatableToTargetInEnclosingTypes (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:48151:29)
    at PullTypeResolver.signatureIsRelatableToTargetWorker (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:48818:52)
    at PullTypeResolver.signatureIsRelatableToTarget (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:48776:36)
    at PullTypeResolver.signatureGroupIsRelatableToTarget (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:48743:61)
    at PullTypeResolver.sourceCallSignaturesAreRelatableToTargetCallSignatures (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:48590:27)
    at PullTypeResolver.sourceIsRelatableToTargetWorker (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:48329:23)
    at PullTypeResolver.sourceIsRelatableToTarget (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:48305:36)
    at PullTypeResolver.sourceIsRelatableToTargetInEnclosingTypes (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:48156:25)
    at PullTypeResolver.sourcePropertyIsRelatableToTargetProperty (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:48559:66)
    at PullTypeResolver.sourcePropertyIsAssignableToTargetProperty (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:48085:69)
    at PullTypeResolver.typeCheckIfTypeExtendsType (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:50257:45)
    at /Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:50427:34
    at Function.PullTypeResolver.typeCheck (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:49358:21)
    at TypeScriptCompiler.getSemanticDiagnostics (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:55508:41)
    at CompilerIterator.moveNextSemanticsPhase (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:56137:45)
    at CompilerIterator.moveNextInternal (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:56087:33)
    at CompilerIterator.moveNext (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:56062:25)
    at BatchCompiler.compile (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:62412:20)
    at BatchCompiler.batchCompile (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:62251:22)
    at TypeScript (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:62928:11)
    at Object.<anonymous> (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc.js:62929:3)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/aaron.mcleod/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/typescript-src-1.0.1.2/lib/typescript-src/support/typescript/bin/tsc:2:1)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

I also tried grabbing the 1.0.1 version of the definition file. Same issue. Based on the typescript-src gem, it uses typescript 1.0.1 I was thinking it used what was installed on the system.

keit commented

I had the same problem today. From master, I used agular.d.ts for ng1.4 and jquery.d.ts.
typescript-src contains 1.0.1 inside the gem. I locally modified typescript-node.rb to use tsc(1.5 beta) and worked.

hey @keit how did you get to use 1.5 beta?

edit: You can change line 17 in typescript-node.rb to point at your tsc executable

cmd = [node, "/usr/local/lib/node_modules/typescript/bin/tsc", *args]

I found that I also had to change line 51 to
raise result.stdout

instead of
raise result.stderr

to get a proper error

Currently I'm not active on this repository. I think it's better to find new maintainers. Is there anyone who is willing to maintain repositories under typescript-ruby?

@tkawachi I'm planning on working on getting this functional for newer versions of typescript this weekend. If I can make that happen, I'd be happy to start maintaining.

@toothrot great! Please let me know when you're ready to start.

keit commented

I think the original dependenct structure of typescript-node-ruby and typescript-src-ruby is great for usability point of view but at the moment TypeScript is rapidly changing so it would be nice if an option to specify locally installed TypeScript is available.

I've added this option and updated Typescript sources: https://github.com/typescript-ruby/typescript-src-ruby#usage

keit commented

Thanks! I tried with 'TypeScript::Src.use_external_tsc = true' option and worked great.