I am new to Typescript. I've been trying to concatenate typescript modules by using the tsc --out
command. But I'm getting some error. There is no information about the error. Below is the process, I've tired.
.ts files I have:
Validation.ts:
module Validation {
export interface StringValidator {
isAcceptable(s: string): boolean;
}
}
ZipCodeValidator.ts:
/// <reference path="Validation.ts" />
module Validation {
var numberRegexp = /^[0‐9]+$/;
export class ZipCodeValidator implements StringValidator {
isAcceptable(s: string) {
return s.length === 5 && numberRegexp.test(s);
}
}
}
LettersOnlyValidator.ts:
/// <reference path="Validation.ts" />
module Validation {
var lettersRegexp = /^[A‐Za‐z]+$/;
export class LettersOnlyValidator implements StringValidator {
isAcceptable(s: string) {
return lettersRegexp.test(s);
}
}
}
Test.ts:
/// <reference path="Validation.ts" />
/// <reference path="LettersOnlyValidator.ts" />
/// <reference path="ZipCodeValidator.ts" />
// Some samples to try
var strings = ['Hello', '98052', '101'];
// Validators to use
var validators: { [s: string]: Validation.StringValidator; } = {};
validators['ZIP code'] = new Validation.ZipCodeValidator();
validators['Letters only'] = new Validation.LettersOnlyValidator();
// Show whether each string passed each validator
strings.forEach(s => {
for (var name in validators) {
console.log('"' + s + '" ' + (validators[name].isAcceptable(s) ? ' matches ' : ' does not match ') + name);
}
});
tsc command:
tsc --out sample.js Test.ts
Error:
error TS6053: File 'ΓÇÉout.ts' not found.
error TS6054: File 'sample.js' must have extension '.ts' or '.d.ts'
Please let me know the way to resolve. And one more, is there any way to concat the typescript module in gulp?