My team and I are new to TypeScript and NodeJS, and we had serious problems getting this project off the ground. This meant being a modular game asset pipeline written in TypeScript for use with NodeJS (I have not been involved in decision making here, and the discussion is still incompatible, but we still need a prototype).
We already have a good architectural idea, but it's hard for me to even run a prototype, because I just can’t turn my head around how the modules work in conjunction with interfaces and external dependencies. Some of our components should also use NodeJS or other library modules (for example, NodeJS.fs for reading / writing files), and we would prefer to be able to use ///referenced.ts to add appropriate files to maintain type safety during development.
An example of the proposed project structure:
/pipeline
/log
- ILog.d.ts
- StdOutLog.ts
- FileLog.ts
- ...
/reader
- IReader.d.ts
- TextReader.ts
- ...
/parser
- IParser.d.ts
- XmlParser.ts
- JsonParser.ts
- ...
/task
- ITask.d.ts
- JsTask.ts
- CliTask.ts
- ...
/...
, , , ( , , , , , JSON XML,...) , (, class GitTask extends CliTask class JpgReader implements IReader).
project/runner :
import pipeline = require('pipeline');
var log = new pipeline.log.FileLog();
log.info("filelog started");
var parser = new pipeline.parser.XmlParser();
parser.parse(somexmldata);
log.info("parsing XML");
, (tm), , TypeScript , , , , , (factory, logger, logitem, logtarget, loglevel). , NodeJS JS , import , , .
, TypeScript NodeJS? , ( FQN, , pipe.log.X, pipe.task.Y .., module export )? , ?
[] basarat, , . , :
error TS2095: Could not find symbol 'LogItem'.
LogItem - , /log StdOutLog.ts . IntelliJ (, LogItem, /log , ). log.LogItem, . . [/Update]
[2] , . / IntelliJ, grunt-ts.
//src/log/LogItem.ts:
class LogItem implements ILogItem {
constructor(level:LogLevel, message:string) {
}
public static create(level:LogLevel, message:string):ILogItem {
return new LogItem(level, message);
}
}
export = LogItem;
//src/log/Log.ts:
class Log implements ILog {
private getLogItem(level:LogLevel, message:string):ILogItem {
return LogItem.create(level, message);
}
}
export = Log;
//src/pipeline.d.ts:
[/2]