tsframework / ts-framework

A Web Framework for Nodejs
http://tsframework.github.io
MIT License
43 stars 6 forks source link

Duplicate identifier 'TS' causes grunt to crash #1

Closed Paradoxis closed 8 years ago

Paradoxis commented 8 years ago

When running tsfw start grunt will complain that the file TSFramework.d.ts contains too many duplicate identifiers 'TS'.

$ tsfw start
(node) util.print is deprecated. Use console.log instead.

> my-app@0.0.0 prestart C:\my-app
> node node_modules/grunt-cli/bin/grunt

Running "ts:build" (ts) task
Compiling...
Fast compile will not work when --out is specified. Ignoring fast compilation
WARNING: TypeScript does not allow external modules to be concatenated with --out. Any exported code may be truncated.  See TypeScript issue #1544 for more details.
Using tsc v1.7.3
C:/my-app/app/Global.ts(2,5): error TS2300: Duplicate identifier 'TS'.
C:/my-app/node_modules/ts-framework/build/TSFramework.d.ts(8,16): error TS2300: Duplicate identifier 'TS'.
C:/my-app/node_modules/ts-framework/build/TSFramework.d.ts(54,16): error TS2300: Duplicate identifier 'TS'.
C:/my-app/node_modules/ts-framework/build/TSFramework.d.ts(100,16): error TS2300: Duplicate identifier 'TS'.
C:/my-app/node_modules/ts-framework/build/TSFramework.d.ts(211,16): error TS2300: Duplicate identifier 'TS'.
C:/my-app/node_modules/ts-framework/build/TSFramework.d.ts(222,16): error TS2300: Duplicate identifier 'TS'.
C:/my-app/node_modules/ts-framework/build/TSFramework.d.ts(226,16): error TS2300: Duplicate identifier 'TS'.
C:/my-app/node_modules/ts-framework/build/TSFramework.d.ts(242,16): error TS2300: Duplicate identifier 'TS'.
C:/my-app/node_modules/ts-framework/build/TSFramework.d.ts(254,16): error TS2300: Duplicate identifier 'TS'.
C:/my-app/node_modules/ts-framework/build/TSFramework.d.ts(333,16): error TS2300: Duplicate identifier 'TS'.
C:/my-app/node_modules/ts-framework/build/TSFramework.d.ts(353,16): error TS2300: Duplicate identifier 'TS'.

>> 11 non-emit-preventing type warnings
>> Error: tsc return code: 2
Warning: Task "ts:build" failed. Use --force to continue.

Aborted due to warnings.

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Users\\[User]\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v4.2.2
npm ERR! npm  v3.8.2
npm ERR! code ELIFECYCLE
npm ERR! my-app@0.0.0 prestart: `node node_modules/grunt-cli/bin/grunt`
npm ERR! Exit status 3
npm ERR!
npm ERR! Failed at the my-app@0.0.0 prestart script 'node node_modules/grunt-cli/bin/grunt'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the my-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node node_modules/grunt-cli/bin/grunt
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs my-app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls my-app
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\my-app\npm-debug.log
child process exited with code 1
Paradoxis commented 8 years ago

I've refactored a large portion of the code to import all modules correctly, but JISON is giving me the worst headache. Feel free to look at and/or implement any of the changes I made over at the forked repo

jhonmike commented 8 years ago

@paradoxis please create PR!

jhonmike commented 8 years ago

teria como criar module TS usando imports?

@Paradoxis Has as create module TS, using imports?

Paradoxis commented 8 years ago

@jhonmike CommonJS modules don't need to be compiled into one module (like they were before), however you can export them all in one file like I was doing in test/integration/app/models.ts. Example:

// TSFramework.ts
export {ApplicationFactory, FactoryConfig} from "./ApplicationFactory";
export {Controller, ActionFilter} from "./Controller";
... all other public classes

// Somewhere in your app
import * as TS from "TSFramework";
class SomeController extends TS.Controller { ... }

This way you can export all classes you want as the "TS" module to expose them in a single class. When it comes to modules I've learned that the only place I ever use them is when I make a class that requires a second namespace. Otherwise its best to just include what you need (Angular 2.0 does this too, rather than importing ALL of angular, you import the bits you need and consume them)

jhonmike commented 8 years ago

ok, we will study a way to finish the updates and create the first stable version of the "framework"

jhonmike commented 8 years ago

@Paradoxis we use TS Framework #7 ? I had understood that it was not recommended!

Paradoxis commented 8 years ago

As far as I've read it's not recommended to do in projects, but lots of libraries seem to use it in this way. I created a demo application with a type definition file called typings/ts-framework.d.ts which declares the module. Doing it this way seems pretty stable.

However I'm still stuck on JISON (after researching a little bit, it turns out to be a lexical grammar thing which gets used in C/C++ when building languages, which seems overkill in the first place), it might be smarter to simply use JavaScript and cache routes in memory instead. (Completely eliminating the need for JISON)

jhonmike commented 8 years ago

I'll be honest, I do not know how to eliminate Jison, but if you know, you can delete it!

Paradoxis commented 8 years ago

I'll work on it some time this week, it should be possible with the new TypeScript decorators and ES6 reflection

jhonmike commented 8 years ago

show will search about it!

I will close the issue and continue the discussion in gitter!