nippur72 / RiotTS

RiotJS for TypeScript
MIT License
101 stars 8 forks source link

RiotTS does not work with typescript 1.6 #9

Closed visopsys closed 9 years ago

visopsys commented 9 years ago

I am running typescript 1.6.2 and it fails to compile with your code. It seems that typescript 1.6 no longer support @template annotation. Can you fix that?

nippur72 commented 9 years ago

strange, I am sure I use typescript@next builds, but will check it.

nippur72 commented 9 years ago

Update: I checked and it works with TS 1.6 (typescript@next).

More likely what you are referring to is the --experimentaDecorators flag (I am guessing).

Since @decorators are not a stable TypeScript feature they must be "enabled". If you are using a VS solution, edit your .csproj this way:

  <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
    <TypeScriptExperimentalDecorators>true</TypeScriptExperimentalDecorators>   // <-- add this line
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)' == 'Release'">
    <TypeScriptExperimentalDecorators>true</TypeScriptExperimentalDecorators>   // <-- add this line
  </PropertyGroup>

Please let me know if this fixes your problem.

visopsys commented 9 years ago

I am working on Mac and cannot have .csproj file to edit. If @decorators is not a stable feature, I think they might deprecate it in the future. Have you thought about that?

nippur72 commented 9 years ago

Decorators is a feature that is going to be added to the ES7 standard, but since it's not official yet, they added the "experimentalDecorators" flag as a reminder for the developer (as they might change some implementation details).

I don't think they'll drop it as everybody are using decorators; consider for example that the Angular2 team switched from AtScript to TypeScript once it started to support decorators.

Back to your issue:

"compilerOptions": {
    "experimentalDecorators": true
  }
visopsys commented 9 years ago

Can you create an example on github of how to use your life without VS? I was trying to compile one of the example file and got an error: error TS2304: Cannot find name 'template'.. My command is tsc --experimentalDecorators --target es6 my-element.ts.

My code is very simple:

@template("my-element.html")
class MyElement extends Riot.Element
{
}

// after the element is defined, we register it in Riot
MyElement.register();
nippur72 commented 9 years ago

If you clone this repo and go in the Test sub-directory you can build the "specRunner" (the page that runs the tests) from the command line without Visual Studio.

Just launch tsc with no parameters, e.g.

$ cd Test
$ tsc

That will produce specRunner.js that is used by specRunner.html (which you can open it in the browser).

This is the tsconfig.json file that makes it possible:

{
    "compilerOptions": {              
        "removeComments": true,
        "out": "specRunner.js",
        "target": "ES5",
        "experimentalDecorators": true,
        "sourceMap": true
    },
    "files": [
        "bower_components/riot-ts/riot-ts.d.ts",
        "elements/specElements.ts",
        "specRunner.ts"
    ]
}

Note the experimentalDecorators flag and the inclusion of riot-ts.d.ts among the files to compile.

Let me know if this is enough for you to get started.

visopsys commented 9 years ago

:+1: Solved my issue. I like your lib. It makes my development much easier. I hope you can invest more time to make this a more mature lib.