typescript-ruby / typescript-rails

An asset pipeline wrapper for the TypeScript language
MIT License
255 stars 30 forks source link

Silently compile even with errors #33

Open yjukaku opened 8 years ago

yjukaku commented 8 years ago

We are currently using the .ts extension for some of our files that are plain javascript. The tsc command will output a .js file regardless of if there are Typescript errors in the .ts file. Is there any way to enable this behavior for this gem?

bdrazhzhov commented 8 years ago

Hello @yjukaku, Not clear what you want. Could you provide an example of file with error, tsc command with appropriate params and what you expect to see after command executing?

yjukaku commented 8 years ago

Save this file with the ts extension in the Rails javascripts folder.

// app/assets/javascripts/plain.js
$(function(){
  console.log("I'm a plain javascript file, using jquery, but saved with a .ts extension");
});

Error:

Typescript error in file 'test/app/assets/javascripts/plain.ts':
/var/folders/36/clbwldqs6039l61kp6q1jxkh0000gn/T/typescript-node20151019-785-1pc7706.ts(1,1): error TS2304: Cannot find name '$'.

Obviously the issue is that we aren't declaring/importing the $. But if I ran this using tsc plain.ts, it would show the same error BUT still output the javascript file plain.js. Basically, I want the option for the typescript-rails gem to still render the page but just log the error messages. I understand why this isn't the default behavior but I think an option is necessary for some cases.

bdrazhzhov commented 8 years ago

Sorry. It is not possible. If you want to use plain js use it in .js-files and don't try to compile via tsc. Or you can fork it and create your own implementation.