electricessence / TypeScript.NET

A JavaScript-Friendly .NET Based TypeScript Library (Moved)
https://github.com/electricessence/TypeScript.NET-Core
Other
251 stars 36 forks source link

Any body know how to add TypeScript.NET to angular2 ? #56

Closed oleksandrmelnychenko closed 7 years ago

oleksandrmelnychenko commented 7 years ago

I have used all packages and Environment.Js throw error that and use eval('required')

oleksandrmelnychenko commented 7 years ago

Collections types not working, Lazy, Integer, Task are working fine

electricessence commented 7 years ago

Interesting. Ive used TypeScript .NET in Angular 2 without any issues before. Can you verify the version of TS .NET you are using? Is this in the browser or in Node? I'm not sure where eval('required') is coming in since eval('require') is what it is actually doing.

electricessence commented 7 years ago

I've looked and all references in the code base to eval('required') are for eval('require');

electricessence commented 7 years ago

Ok here's the catch: You want to use typescript-dotnet-commonjs as your dist version. Because Angular2 should do all the browserify style bundling with it.

electricessence commented 7 years ago

So when you install TypeScript .NET from npm. Use:

npm install typescript-dotnet-commonjs --save

electricessence commented 7 years ago

Let me know if that helps. There may be some other config stuff you need to do to be sure angular2 knows where to pull from, but I'm pretty sure that's it.

oleksandrmelnychenko commented 7 years ago

issue

oleksandrmelnychenko commented 7 years ago

image

oleksandrmelnychenko commented 7 years ago

when i include IEnumerable it's break, for example i use Lazy it;s okay, working, but LINQ not and many others libs also are throw this

oleksandrmelnychenko commented 7 years ago

I have used lasted angular CLI beta 26,

electricessence commented 7 years ago

Oh interesting. You are using ES6?

oleksandrmelnychenko commented 7 years ago

yes

electricessence commented 7 years ago

And what's transpiling to ES5? Something built in to Angular?

electricessence commented 7 years ago

I'm looking into this now. Your issue probably doesn't happen with ES5.

oleksandrmelnychenko commented 7 years ago

image

oleksandrmelnychenko commented 7 years ago

What interesting that, some types are working

electricessence commented 7 years ago

Ok so you ARE targeting ES5. So you can't use "typescript-dotnet-es6". You have to use "typescript-dotnet-commonjs" or "typescript-dotnet-umd".

oleksandrmelnychenko commented 7 years ago

i have used "typescript-dotnet-umd" at the beginning

oleksandrmelnychenko commented 7 years ago

https://1drv.ms/u/s!AlTIWb5-A76AhN18BO3U8rx-Wt9diQ

electricessence commented 7 years ago

The UMD version can be troublesome because of conflicts with WebPack etc. Try -commonjs.

electricessence commented 7 years ago

Sorry, the Zip file is being flagged with a virus. Can you share over github?

electricessence commented 7 years ago

Preferrably, just try typescript-dotnet-commonjs instead and let me know if that works. My working Angular2 app uses it.

oleksandrmelnychenko commented 7 years ago

image

oleksandrmelnychenko commented 7 years ago

image

electricessence commented 7 years ago

@oleksandrmelnychenko Hmm... Not having a module loader ('require') is concerning.

oleksandrmelnychenko commented 7 years ago

https://github.com/oleksandrmelnychenko/ng2ForTest

electricessence commented 7 years ago

Ok. So again, Webpack is giving me woes. I can see here that it must be recompiling the code and stripping out 'require' references. I'll need to look at this more. Any chance you can turn off webpack for now?

electricessence commented 7 years ago

Oh wait. It works now?

oleksandrmelnychenko commented 7 years ago

i dont hurry up with it, just want to use in my own company web app, so maybe you can fix it.

electricessence commented 7 years ago

So wait, with those two screenshots... Is it working or not?

electricessence commented 7 years ago

Oh I see.

oleksandrmelnychenko commented 7 years ago

on the second screenshot Task is working, but if i use another type, for example LazyPromise or Collection, it doesn't

electricessence commented 7 years ago

Well if you give me a few minutes, work with me, we'll fix this. It doesn't take me but a second to redeploy.

oleksandrmelnychenko commented 7 years ago

sure

electricessence commented 7 years ago

I'm concerned that I'm unable to call for require :( If webpack eliminates it from the loading context then 1) no dynamic loading, 2) some features will be disabled. But I can definitely put a try catch on the eval.

oleksandrmelnychenko commented 7 years ago

I think you need also add EventAggregator in this framework, i can help if needed. It can be full tooling for all life cases :)

electricessence commented 7 years ago

Stand by. Build pending.

oleksandrmelnychenko commented 7 years ago

no problem, sure

electricessence commented 7 years ago

You won't be able to call .linq or .linqAsync on any collection. You'll have to use Enumerable(x) to get a linq object.

oleksandrmelnychenko commented 7 years ago

okay, but what about LazyPromise, or some others types? Integer(1) is also okay

oleksandrmelnychenko commented 7 years ago

LinkedList also not.

electricessence commented 7 years ago

Yeah, just hold on. All should be well.

electricessence commented 7 years ago

I apologize, but I struggled with Webpack for a while but didn't run into any errors like this. So I appreciate you reporting this to me so it can be fixed.

electricessence commented 7 years ago

All set. 4.7.14 is up on NPM. Please update and try again.

oleksandrmelnychenko commented 7 years ago

okay, some mins

oleksandrmelnychenko commented 7 years ago

I think it's brilliant now

oleksandrmelnychenko commented 7 years ago

One thing more, i did dummy code, it's throw the exception, in core of framework, it can be good console will display it

electricessence commented 7 years ago

On the last comment, could you be more specific?

oleksandrmelnychenko commented 7 years ago

sure, let me prepare information

electricessence commented 7 years ago

So did we fix this issue? May I close?