Pregunta

We are creating a typescript app that will have about 250 classes. Coming from the C# world, we are creating a .ts file for each class. And that feels appropriate as each class/file will be between 20 and 500 lines of code. And it keeps things clean for the object orientation.

Which leads to a couple of questions for all this.

  1. Should we have a unique module name per .ts file, per folder, or per project (a folder and all its sub folders)?
  2. When a class is dependent on other classes, should we wrap that .ts file in a require/define (we use require.js) for the dependencies? Or should we have a single massive require in our root .js file (listing all 250+ files)? Or is there another approach we should use?
  3. We are having to put in a ton of /// <reference ... /> statements. Is there a way to have global ones? Or a way to put wild cards in so we can have a single reference call for all .ts files in a folder?
  4. Any other suggestions for what we should and should not do for a project this large?

Update: This is for a client side app that will run in a browser. We are presently using requirejs. It is a lot of code, but all of the code is needed in the browser (sooner or later).

I want it to be quick/easy to run/debug when coding and then, probably building it differently, have it be fast/small to upload. Half of us develop in WebStorm and half in VisualStudio.

¿Fue útil?

Solución

Should we have a unique module name per .ts file

Yes use amd/commonjs : https://www.youtube.com/watch?v=KDrWLMUY0R0&hd=1

per folder

Yes create an index.js that exports everything from a folder.

When a class is dependent on other classes, should we wrap that .ts file in a require/define (we use require.js) for the dependencies?

no. Use the built in import statement in TypeScript

We are having to put in a ton of /// statements. Is there a way to have global ones?

Yes look at reference files https://github.com/grunt-ts/grunt-ts#reference-file-generation

Any other suggestions for what we should and should not do for a project this large?

Depend on TypeScript as much as you can and then refactoring to a different pattern will not be too hard when one emerges (you should get compile errors)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top