Skip to content

ts module not found issue #51

Open
@ziyouchutuwenwu

Description

@ziyouchutuwenwu

i removed coffie-script from gemfile

gem 'typescript-rails'

routes.rb

Rails.application.routes.draw do
  root 'welcome#index'
end

views/welcome/index.html.erb

<p id="p1">aaaaa</p>

assets/javascripts/welcome.ts

import {Greeter} from "./greeter";

window.onload = function () {
    let greeter = new Greeter();
    greeter.setName("what's this");
    document.getElementById("p1").innerHTML = greeter.greet();
};

greeter.ts in assets/javascripts/

class Greeter {
    private _greeting :string;

    setName(name :string){
        this._greeting = name;
    }

    greet() {
        return this._greeting;
    }
}

export { Greeter }

i added this to application.rb to support multi ts files compiling

Typescript::Rails::Compiler.default_options = %w(--target ES5 --noImplicitAny --module commonjs)

when i run rails in dev mode, here are the error snapshot
111

but if a copy copy class code from greeter.ts to welcome.ts, it runs ok
is this a bug? if not, how can i do?

thank you very much!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions