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

Errors to build project #49

Closed lommez closed 7 years ago

lommez commented 7 years ago

I can't build my project. I'm attaching here an image showing the errors. https://portalvhdsdtx1sqp9m14cf.blob.core.windows.net/vhds/TypeScriptNet_Errors.jpg

It looks like it's missing some files.

electricessence commented 7 years ago

@lommez Will look into ASAP.

electricessence commented 7 years ago

There looks to have been some missing files from check-in to GitHub but I'm not sure if that is affecting you. Could you try again with updated 4.0.1 and see if you still have the same issue? I'm available today to fix this.

lommez commented 7 years ago

Hi @electricessence , Thanks for quick reply. I'm going to try with the new version. Is already available in github?

electricessence commented 7 years ago

@lommez One moment. Publishing and verifying.

lommez commented 7 years ago

Thanks @electricessence

electricessence commented 7 years ago

@lommez Ok everything looks good. Try now. How have you been getting the files?

electricessence commented 7 years ago

Are you getting the entire GitHub repo or are you using NPM?

lommez commented 7 years ago

I'm getting the entire GitHub

electricessence commented 7 years ago

@lommez Is there a reason why? How are you using in your project? The most common way to integrate is by using NPM and picking a specific dist...

lommez commented 7 years ago

No specific reason for that. Even using Visual Studio the best way is to use the NPM package?

electricessence commented 7 years ago

@lommez So it's based upon your use case really. But typically speaking, let's say you are developing a NodeJS project. Then I'm guessing it would be more straight forward to simply npm install typescript-dotnet-commonjs --save instead of pulling manually from GitHub.

This is also true for web projects, you could easily npm install typescript-dotnet-umd --save

Or you could use Bower which I believe is integrated with VS.

The other way is to simply cherry pick the dist you need and include it in your project. But as you can imagine that will be problematic to update later.

electricessence commented 7 years ago

I'll need to update the release for Bower (doing now).

lommez commented 7 years ago

In my case, i'm developing web project and my application is using requirejs. I'll try to install it by using the command: npm install typescript-dotnet-commonjs --save

electricessence commented 7 years ago

Don't do that

electricessence commented 7 years ago

If you are using requirejs then use the AMD dist specifically.

electricessence commented 7 years ago

npm install typescript-dotnet-amd --save https://www.npmjs.com/package/typescript-dotnet-amd

electricessence commented 7 years ago

That way you are leveraging an already minified and web ready version.

lommez commented 7 years ago

Thank you for the advice

electricessence commented 7 years ago

No problem!

electricessence commented 7 years ago

If you are familiar with RequireJS then this should work very nicely with your project. All classes are separate modules and load on demand. If you intend on using LINQ then note that

linqAsync(callback?: (linq: ILinqEnumerable<T>) => void): ILinqEnumerable<T>;

exists as part of CollectionBase. So you can call it at anytime to dynamically load the LINQ extensions. Once that has resolved the first time, you can then call .linq from then on.

electricessence commented 7 years ago

Please let me know if this fixes your issue.

lommez commented 7 years ago

The npm packages are done?

electricessence commented 7 years ago

Yes they are up. Is that your question?

lommez commented 7 years ago

Now is building perfectly! But i'm having some trouble to download the javascript files using requirejs. Here is my tsconfig.json

{ "compilerOptions": { "module": "amd", "noImplicitAny": false, "noEmitOnError": true, "removeComments": false, "sourceMap": true, "target": "es5", "outDir": "typescript/generated" }, "exclude": [ "node_modules", "wwwroot" ] }

So when my application is trying to download for example, the file TimeSpan.js from: http://myApplication/typescript/libs/typescript-dotnet-amd/System/Time/TimeSpan.js that file can't be found because the physical files ares stored in /libs/typescript-dotnet-amd.

Do you know if there is any way to tell requirejs to download those files from that directory?

electricessence commented 7 years ago

@lommez YES!

electricessence commented 7 years ago

So there's some tricks in RequireJS. You can set 'aliases' for any directory.

electricessence commented 7 years ago

So what I typically do... Is in my imports I will put

import {TimeSpan} from 'typescript-dotnet-amd/System/Time/TimeSpan';

And by using the require config I can define an alias for:

requirejs.config({
    paths: {
        "typescript-dotnet-amd": "[ the path ]"
    },
});
electricessence commented 7 years ago

You can even omit the -amd from that point on... The only caveat is that of course most people using TypeScript will want the types to come through automatically. And as long as that works, then great.

electricessence commented 7 years ago

@lommez if you want to see this in action: https://github.com/electricessence/TypeScript.NET/tree/master/tests/qunit I added these qunit tests when I started to ensure that AMD continued to work and in the case of WebStorm everything works perfectly. It resolves the types and everything.

lommez commented 7 years ago

Thanks so much! I'll check those tests

electricessence commented 7 years ago

@lommez You're welcome :)

lommez commented 7 years ago

@electricessence , now is working perfectly. It was missing in my tsconfig the path for the typescript-dotnet-amd. Congratulations on your excellent work.