<commit_before># TypeScript-Sprockets

Please note that this is currently a *WORK-IN-PROGRESS*.

Extends Sprockets to work with TypeScript (fork of [typescript-rails](typescript-ruby/typeScript-rails)) without Rails. This should make it possible to use TypeScript with [middleman-sprockets](https://github.com/middleman/middleman-sprockets) and/or [blade](https://github.com/javan/blade).

This gem assumes you are installing TypeScript locally with npm.

The credit for the overall structure and the tests goes to the people that wrote the [typescript-rails](https://github.com/typescript-ruby/typescript-rails) Gem, since I shamelessly copy&pasted some of their code.

## Requirements

The current version requires that [node.js](http://nodejs.org/) is
installed on the system.

## Installation

Add this line to your application's Gemfile:

    gem 'typescript-sprockets', 'git: 'https://github.com/preetpalS/typescript-sprockets.git', tag: '0.0.9', require: 'typescript-sprockets'

And then execute:

    $ bundle

## Usage

After the sprockets gem (and this gem) is loaded, add the following lines of code:

    require 'sprockets' # might not be necessary depending on when/where this line of code is executed
    require 'typescript-sprockets' # might not be necessary depending on when/where this line of code is executed
    ::Typescript::Sprockets::TypescriptProcessor.register

Then just add a `.js.ts` file in your `app/assets/javascripts` directory and include it just like you are used to do.

Configurations:

```
# Its defaults are `['--removeComments', '--noImplicitAny', '--noEmitOnError']`.
Typescript::Sprockets::TypescriptProcess.options(compiler_flags: ['--removeComments', '--noImplicitAny', '--noEmitOnError'], compiler_command: 'node node_modules/typescript/bin/tsc')
```

## Referenced TypeScript dependencies

`typescript-rails` recurses through all [TypeScript-style](https://github.com/teppeis/typescript-spec-md/blob/master/en/ch11.md#1111-source-files-dependencies) referenced files and tells its [`Sprockets::Context`](https://github.com/sstephenson/sprockets/blob/master/lib/sprockets/context.rb) that the TS file being processed [`depend`s`_on`](https://github.com/sstephenson/sprockets#the-depend_on-directive) each file listed as a reference. This activates Sprocket’s cache-invalidation behavior when any of the descendant references of the root TS file is changed.

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

## Maintainers

<NAME>

## Authors

<NAME> <<EMAIL>>

Authors of the original repository that this is repository is a fork of:

<NAME> <<EMAIL>>
<NAME> <<EMAIL>>
<commit_msg>Typo fix in README.md code sample<commit_after># TypeScript-Sprockets

Please note that this is currently a *WORK-IN-PROGRESS*.

Extends Sprockets to work with TypeScript (fork of [typescript-rails](typescript-ruby/typeScript-rails)) without Rails. This should make it possible to use TypeScript with [middleman-sprockets](https://github.com/middleman/middleman-sprockets) and/or [blade](https://github.com/javan/blade).

This gem assumes you are installing TypeScript locally with npm.

The credit for the overall structure and the tests goes to the people that wrote the [typescript-rails](https://github.com/typescript-ruby/typescript-rails) Gem, since I shamelessly copy&pasted some of their code.

## Requirements

The current version requires that [node.js](http://nodejs.org/) is
installed on the system.

## Installation

Add this line to your application's Gemfile:

    gem 'typescript-sprockets', git: 'https://github.com/preetpalS/typescript-sprockets.git', tag: '0.0.9', require: 'typescript-sprockets'

And then execute:

    $ bundle

## Usage

After the sprockets gem (and this gem) is loaded, add the following lines of code:

    require 'sprockets' # might not be necessary depending on when/where this line of code is executed
    require 'typescript-sprockets' # might not be necessary depending on when/where this line of code is executed
    ::Typescript::Sprockets::TypescriptProcessor.register

Then just add a `.js.ts` file in your `app/assets/javascripts` directory and include it just like you are used to do.

Configurations:

```
# Its defaults are `['--removeComments', '--noImplicitAny', '--noEmitOnError']`.
Typescript::Sprockets::TypescriptProcess.options(compiler_flags: ['--removeComments', '--noImplicitAny', '--noEmitOnError'], compiler_command: 'node node_modules/typescript/bin/tsc')
```

## Referenced TypeScript dependencies

`typescript-rails` recurses through all [TypeScript-style](https://github.com/teppeis/typescript-spec-md/blob/master/en/ch11.md#1111-source-files-dependencies) referenced files and tells its [`Sprockets::Context`](https://github.com/sstephenson/sprockets/blob/master/lib/sprockets/context.rb) that the TS file being processed [`depend`s`_on`](https://github.com/sstephenson/sprockets#the-depend_on-directive) each file listed as a reference. This activates Sprocket’s cache-invalidation behavior when any of the descendant references of the root TS file is changed.

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

## Maintainers

<NAME>

## Authors

<NAME> <<EMAIL>>

Authors of the original repository that this is repository is a fork of:

<NAME> <<EMAIL>>
<NAME> <<EMAIL>>

{'fraction_non_alphanumeric': 0.11215283920042456, 'fraction_numerical': 0.004953122235980895, 'mean_word_length': 4.9578503688092725, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3536533', 'n_tokens_mistral': 1771, 'n_tokens_neox': 1700, 'n_words': 577}