├── tasks ├── scratch.ts └── modules │ ├── templateCache.js │ ├── templateCache.ts │ ├── reference.js │ ├── html2ts.js │ ├── defaults.js │ ├── defaults.ts │ ├── cacheUtils.js │ └── reference.ts ├── test ├── html │ └── src │ │ ├── foo.ts │ │ ├── bar.ts │ │ └── test.tpl.html ├── abtest │ ├── c.ts │ ├── a.ts │ ├── b.ts │ └── reference.ts ├── htmlOutDir │ ├── src │ │ ├── foo.ts │ │ ├── bar.ts │ │ └── test.tpl.html │ └── reference.ts ├── issue_392 │ ├── app │ │ ├── 392-a.ts │ │ └── 392-a.spec.ts │ ├── typings │ │ └── 392-testtype.ts │ └── issue_392-tsconfig.json ├── simple │ ├── js │ │ ├── .baseDir.d.ts │ │ └── zoo.d.ts │ └── ts │ │ └── zoo.ts ├── work │ ├── inside │ │ ├── tada.ts │ │ ├── tada2.ts │ │ └── work3.ts │ ├── work.ts │ └── work2.ts ├── htmlOutDirFlat │ ├── src │ │ ├── foo.ts │ │ ├── bar.ts │ │ └── test.tpl.html │ └── reference.ts ├── issue_397 │ └── src │ │ ├── app │ │ └── 397-a.ts │ │ ├── typings │ │ └── 397-testtype.d.ts │ │ ├── other_typings │ │ └── 397-othertesttype.d.ts │ │ └── issue_397-tsconfig.json ├── multifile │ ├── a │ │ ├── c.ts │ │ ├── a.ts │ │ ├── b.ts │ │ └── reference.ts │ └── b │ │ ├── c.ts │ │ ├── a.ts │ │ ├── b.ts │ │ └── reference.ts ├── nocompile │ ├── c.ts │ ├── a.ts │ ├── b.ts │ └── reference.ts ├── tsconfig │ ├── otherFiles │ │ ├── other.ts │ │ ├── that.ts │ │ └── this.ts │ └── files │ │ └── validtsconfig.ts ├── bothcomments │ └── a.ts ├── issue_392_2 │ ├── app │ │ └── subfolder │ │ │ ├── test1.ts │ │ │ └── test1.spec.ts │ ├── compiled │ │ └── compiled │ │ │ └── shouldnotbefound.ts │ └── tsconfig.json ├── tsconfig_artifact │ ├── blank_tsconfig.json │ ├── empty_object_literal_tsconfig.json │ ├── extends │ │ ├── configs │ │ │ └── base.json │ │ ├── tsconfig.json │ │ └── tsconfig.nostrictnull.json │ ├── invalid_tsconfig.json │ ├── test_simple_with_out.json │ ├── test_simple_with_outFile.json │ ├── tsconfig-grunt-ts.json │ ├── tab_indent_tsconfig.json │ ├── three_spaces_indent_tsconfig.json │ ├── test_include_wildcard.json │ ├── four_spaces_indent_tsconfig.json │ ├── mixed_indent_tsconfig.json │ ├── simple_filesGlob_tsconfig.json │ ├── test_exclude_tsconfig.json │ ├── test_include_tsconfig.json │ ├── tab_indent_tsconfig.expected.json │ ├── test_simple_tsconfig.json │ ├── newlineConfigs │ │ ├── lf_newline_tsconfig.json.ts │ │ ├── mixed_newline_tsconfig.json.ts │ │ ├── crlf_newline_tsconfig.json.ts │ │ ├── lf_newline_tsconfig.expected.json.ts │ │ ├── lf_newline_tsconfig.json.js │ │ ├── mixed_newline_tsconfig.expected.json.ts │ │ ├── mixed_newline_tsconfig.json.js │ │ ├── crlf_newline_tsconfig.json.js │ │ ├── crlf_newline_tsconfig.expected.json.ts │ │ ├── lf_newline_tsconfig.expected.json.js │ │ ├── mixed_newline_tsconfig.expected.json.js │ │ └── crlf_newline_tsconfig.expected.json.js │ ├── three_spaces_indent_tsconfig.expected.json │ ├── mixed_indent_tsconfig.expected.json │ ├── four_spaces_indent_tsconfig.expected.json │ └── full_valid_tsconfig.json ├── amdtest │ ├── c.ts │ ├── a.ts │ └── b.ts ├── files_testFailedCompilation │ ├── b │ │ └── a.ts │ └── a │ │ └── syntaxError.ts ├── noEmitOnError │ └── testNoEmitOnError.ts ├── baseDirOption │ ├── baseDirSpecified │ │ └── foo │ │ │ └── bar.ts │ └── baseDirNotSpecified │ │ └── foo │ │ └── bar.ts ├── htmlTemplateGlob │ ├── test.html │ ├── doNotTranspile.html │ └── othercompilation.ts ├── referenceReplaced │ ├── referencing2.ts │ ├── referencing1.ts │ └── referenced-grunt-ts.ts ├── sourceroot │ └── src │ │ ├── a.ts │ │ ├── nested │ │ ├── b.html │ │ └── b.ts │ │ └── reference.ts ├── vsproj │ ├── ignoreFiles │ │ └── ignoreFiles_test.ts │ ├── vsprojtest2.ts │ ├── vsprojtest1.ts │ └── testproject.csproj ├── transform │ └── ts │ │ ├── foo │ │ ├── b │ │ │ ├── b1.ts │ │ │ └── b2.ts │ │ ├── a │ │ │ ├── A2.ts │ │ │ ├── A1.ts │ │ │ └── index.ts │ │ └── index.ts │ │ ├── bar │ │ └── c │ │ │ ├── c1.ts │ │ │ └── c2.ts │ │ └── rootLevel.ts ├── expected │ ├── customcompiler │ │ └── js │ │ │ └── foo.js │ ├── transform │ │ ├── ts │ │ │ ├── foo │ │ │ │ ├── b │ │ │ │ │ ├── b1.ts │ │ │ │ │ └── b2.ts │ │ │ │ ├── a │ │ │ │ │ ├── A2.ts │ │ │ │ │ ├── A1.ts │ │ │ │ │ └── index.ts │ │ │ │ └── index.ts │ │ │ ├── bar │ │ │ │ └── c │ │ │ │ │ ├── c1.ts │ │ │ │ │ └── c2.ts │ │ │ └── rootLevel.ts │ │ └── js │ │ │ ├── foo │ │ │ ├── b │ │ │ │ ├── b1.js │ │ │ │ └── b2.js │ │ │ ├── a │ │ │ │ ├── A1.js │ │ │ │ ├── index.js │ │ │ │ └── A2.js │ │ │ └── index.js │ │ │ ├── rootLevel.js │ │ │ └── bar │ │ │ └── c │ │ │ ├── c1.js │ │ │ └── c2.js │ ├── noEmitOnError │ │ └── testNoEmitOnError_false.js │ ├── preserveConstEnums │ │ ├── test_preserveConstEnums_false.js │ │ └── test_preserveConstEnums_true.js │ ├── es6 │ │ ├── es6 │ │ │ └── stringTemplate.js │ │ └── es5 │ │ │ └── stringTemplate.js │ ├── vsproj │ │ └── ignoreSettings │ │ │ └── vsprojtest1.js │ ├── amdloader │ │ └── js │ │ │ └── app │ │ │ ├── loader.bin.js │ │ │ └── loader.js │ ├── abtest │ │ ├── reference.ts │ │ ├── out.js.map │ │ └── out.js │ ├── htmlExternal │ │ └── html.external.html.ts │ ├── suppressImplicitAnyIndexErrors │ │ └── test_suppressImplicitAnyIndexError_true.js │ ├── references-transform │ │ └── references-transform.js │ ├── fail │ │ └── ts │ │ │ └── deep │ │ │ └── work.ts │ ├── templatecache │ │ └── js │ │ │ └── templateCache.js │ ├── simple │ │ └── js │ │ │ ├── zoo.d.ts │ │ │ └── zoo.js │ ├── allowJs │ │ └── result.js │ ├── htmlSnakeModuleName │ │ └── out.js │ ├── varreplacedtest │ │ ├── grunt-ts-test.js.map │ │ └── grunt-ts-test.js │ ├── htmlTemplate │ │ └── out.js │ ├── files_ObjectFormat │ │ ├── a.js │ │ └── b.js │ ├── out with spaces │ │ └── zoo.js │ ├── simple_with_rootDir │ │ └── js │ │ │ └── ts │ │ │ └── zoo.js │ └── nestedSources │ │ └── zoo.js ├── amdloader │ ├── index.html │ └── ts │ │ ├── app │ │ ├── classa.ts │ │ ├── app.ts │ │ ├── deep │ │ │ ├── deeper │ │ │ │ └── classd.ts │ │ │ ├── classc.ts │ │ │ └── classb.ts │ │ └── reference.ts │ │ └── test │ │ ├── classt.ts │ │ ├── test.ts │ │ ├── deep │ │ ├── deeper │ │ │ └── classw.ts │ │ ├── classv.ts │ │ └── classu.ts │ │ ├── extendedAppCode.ts │ │ └── reference.ts ├── allowJs │ ├── allowJsConsumer.ts │ └── allowJsLibrary.js ├── definitelytypedtest │ ├── d.ts │ │ └── DefinitelyTyped │ │ │ └── async │ │ │ ├── async.d.key │ │ │ └── async.d.ts │ └── test.ts ├── es6 │ └── stringTemplate.ts ├── references-transform-library.d.ts ├── templatecache │ ├── index.html │ └── ts │ │ ├── classa.ts │ │ ├── app.ts │ │ ├── deep │ │ ├── classc.ts │ │ └── classb.ts │ │ └── reference.ts ├── htmlSnakeModuleName │ ├── src │ │ ├── snake-module-name.tpl.html │ │ └── foo.ts │ └── reference.ts ├── htmlTemplate │ ├── src │ │ ├── advanced.$$template.name.tpl.html │ │ └── foo.ts │ └── reference.ts ├── outdirtest │ └── ts │ │ └── source.ts ├── withwrongmodule │ └── ts │ │ ├── Foo.ts │ │ └── Main.ts ├── htmlExternal │ └── html.external.html ├── withemptymodule │ └── ts │ │ ├── Main.ts │ │ ├── Bar.ts │ │ └── Foo.ts ├── fail │ └── ts │ │ └── deep │ │ ├── fail.ts │ │ └── work.ts ├── preserveConstEnums │ └── test_preserveConstEnums.ts ├── customcompiler │ └── ts │ │ └── foo.ts ├── suppressImplicitAnyIndexErrors │ └── test_suppressImplicitAnyIndexError.ts ├── references-transform │ └── references-transform.ts ├── issue_426_baseUrl │ └── src │ │ ├── issue_426_1.tsconfig.json │ │ ├── issue_426_2.tsconfig.json │ │ └── issue_426_3.tsconfig.json ├── failontypeerror │ └── ts │ │ └── fail.ts ├── testHelpers.ts ├── testHelpers.js ├── compilerTests.js ├── compilerTests.ts ├── test.ts └── test.js ├── tasks-internal ├── scratch.ts ├── scratch.js └── modules │ ├── templateCache.ts │ ├── templateCache.js │ ├── defaults.js │ ├── defaults.ts │ ├── reference.js │ ├── reference.ts │ └── html2ts.js ├── customcompiler ├── tsc └── lib.scripthost.d.ts ├── .vscode ├── settings.json └── launch.json ├── .gitattributes ├── .travis.yml ├── defs ├── detect-newline │ └── detect-newline.d.ts ├── detect-indent │ └── detect-indent.d.ts ├── tsd.d.ts └── nodeunit │ └── nodeunit.d.ts ├── AUTHORS ├── .npmignore ├── custom.TypeScript.targets ├── sample ├── commonjs │ └── Gruntfile.js └── Gruntfile.js ├── .gitignore ├── tsd.json ├── docs ├── fast.md ├── DisableVisualStudioBuild.md ├── amdLoader.md ├── DetailedGettingStartedInstructions.md └── html2ts.md ├── .jshintrc ├── grunt-ts.sln ├── LICENSE ├── tsconfig.json ├── tslint.json └── package.json /tasks/scratch.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/html/src/foo.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tasks-internal/scratch.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/abtest/c.ts: -------------------------------------------------------------------------------- 1 | class C { } -------------------------------------------------------------------------------- /test/htmlOutDir/src/foo.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/issue_392/app/392-a.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/simple/js/.baseDir.d.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/work/inside/tada.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/work/inside/tada2.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/htmlOutDirFlat/src/foo.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/issue_392/app/392-a.spec.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/issue_397/src/app/397-a.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/multifile/a/c.ts: -------------------------------------------------------------------------------- 1 | class C { } -------------------------------------------------------------------------------- /test/multifile/b/c.ts: -------------------------------------------------------------------------------- 1 | class C { } -------------------------------------------------------------------------------- /test/nocompile/c.ts: -------------------------------------------------------------------------------- 1 | class C { } -------------------------------------------------------------------------------- /test/tsconfig/otherFiles/other.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/tsconfig/otherFiles/that.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/tsconfig/otherFiles/this.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/issue_392/typings/392-testtype.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/bothcomments/a.ts: -------------------------------------------------------------------------------- 1 | class A extends B { } -------------------------------------------------------------------------------- /test/issue_392_2/app/subfolder/test1.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/tsconfig_artifact/blank_tsconfig.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/amdtest/c.ts: -------------------------------------------------------------------------------- 1 | class C { } 2 | export = C; -------------------------------------------------------------------------------- /test/issue_392_2/app/subfolder/test1.spec.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/issue_397/src/typings/397-testtype.d.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/files_testFailedCompilation/b/a.ts: -------------------------------------------------------------------------------- 1 | class A { } -------------------------------------------------------------------------------- /test/issue_392_2/compiled/compiled/shouldnotbefound.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/issue_397/src/other_typings/397-othertesttype.d.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/noEmitOnError/testNoEmitOnError.ts: -------------------------------------------------------------------------------- 1 | var x: string = 5; -------------------------------------------------------------------------------- /tasks-internal/scratch.js: -------------------------------------------------------------------------------- 1 | //# sourceMappingURL=scratch.js.map -------------------------------------------------------------------------------- /test/baseDirOption/baseDirSpecified/foo/bar.ts: -------------------------------------------------------------------------------- 1 | class Bar {} 2 | -------------------------------------------------------------------------------- /customcompiler/tsc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | require('./tsc.js') 3 | -------------------------------------------------------------------------------- /test/baseDirOption/baseDirNotSpecified/foo/bar.ts: -------------------------------------------------------------------------------- 1 | class Bar {} 2 | -------------------------------------------------------------------------------- /test/tsconfig_artifact/empty_object_literal_tsconfig.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/htmlTemplateGlob/test.html: -------------------------------------------------------------------------------- 1 |
This is an HTML fragment
2 | -------------------------------------------------------------------------------- /test/referenceReplaced/referencing2.ts: -------------------------------------------------------------------------------- 1 | referencingTest.city = ""; 2 | -------------------------------------------------------------------------------- /test/abtest/a.ts: -------------------------------------------------------------------------------- 1 | /// 2 | class A extends B { } -------------------------------------------------------------------------------- /test/abtest/b.ts: -------------------------------------------------------------------------------- 1 | /// 2 | class B extends C{ } -------------------------------------------------------------------------------- /test/multifile/a/a.ts: -------------------------------------------------------------------------------- 1 | /// 2 | class A extends B { } -------------------------------------------------------------------------------- /test/multifile/a/b.ts: -------------------------------------------------------------------------------- 1 | /// 2 | class B extends C{ } -------------------------------------------------------------------------------- /test/multifile/b/a.ts: -------------------------------------------------------------------------------- 1 | /// 2 | class A extends B { } -------------------------------------------------------------------------------- /test/multifile/b/b.ts: -------------------------------------------------------------------------------- 1 | /// 2 | class B extends C{ } -------------------------------------------------------------------------------- /test/nocompile/a.ts: -------------------------------------------------------------------------------- 1 | /// 2 | class A extends B { } -------------------------------------------------------------------------------- /test/nocompile/b.ts: -------------------------------------------------------------------------------- 1 | /// 2 | class B extends C{ } -------------------------------------------------------------------------------- /test/sourceroot/src/a.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | class A {} -------------------------------------------------------------------------------- /test/vsproj/ignoreFiles/ignoreFiles_test.ts: -------------------------------------------------------------------------------- 1 | var x = "hello"; 2 | console.log(x); -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "typescript.tsdk": "./node_modules/typescript/lib" 3 | } -------------------------------------------------------------------------------- /test/amdtest/a.ts: -------------------------------------------------------------------------------- 1 | import B = require('b'); 2 | export class A extends B { } 3 | 4 | -------------------------------------------------------------------------------- /test/transform/ts/foo/b/b1.ts: -------------------------------------------------------------------------------- 1 | 2 | export class B1 { 3 | b1() { return "b1" } 4 | } -------------------------------------------------------------------------------- /test/expected/customcompiler/js/foo.js: -------------------------------------------------------------------------------- 1 | var foo = [1, ]; 2 | //# sourceMappingURL=foo.js.map -------------------------------------------------------------------------------- /test/html/src/bar.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | var boo = test.tpl.html; -------------------------------------------------------------------------------- /test/htmlTemplateGlob/doNotTranspile.html: -------------------------------------------------------------------------------- 1 |
This file should not be transpiled
2 | -------------------------------------------------------------------------------- /test/vsproj/vsprojtest2.ts: -------------------------------------------------------------------------------- 1 | 2 | //this came from file vsprojtest2.ts 3 | var test2 = 'test'; -------------------------------------------------------------------------------- /test/amdloader/index.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/expected/transform/ts/foo/b/b1.ts: -------------------------------------------------------------------------------- 1 | 2 | export class B1 { 3 | b1() { return "b1" } 4 | } -------------------------------------------------------------------------------- /test/html/src/test.tpl.html: -------------------------------------------------------------------------------- 1 |
Some content
2 | some other content -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set default behaviour, in case users don't have core.autocrlf set. 2 | * text=auto 3 | -------------------------------------------------------------------------------- /test/allowJs/allowJsConsumer.ts: -------------------------------------------------------------------------------- 1 | import {writeIt} from './allowJsLibrary'; 2 | 3 | writeIt("test"); 4 | -------------------------------------------------------------------------------- /test/definitelytypedtest/d.ts/DefinitelyTyped/async/async.d.key: -------------------------------------------------------------------------------- 1 | C9E5903D-85FB-4127-A487-0F8479942F42 -------------------------------------------------------------------------------- /test/es6/stringTemplate.ts: -------------------------------------------------------------------------------- 1 | { 2 | let name = "World"; 3 | console.log(`Hello ${name}!`); 4 | } -------------------------------------------------------------------------------- /test/htmlOutDir/src/bar.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | var boo = test.tpl.html; -------------------------------------------------------------------------------- /test/htmlOutDir/src/test.tpl.html: -------------------------------------------------------------------------------- 1 |
Some content
2 | some other content -------------------------------------------------------------------------------- /test/htmlOutDirFlat/src/bar.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | var boo = test.tpl.html; -------------------------------------------------------------------------------- /test/referenceReplaced/referencing1.ts: -------------------------------------------------------------------------------- 1 | var referencingTest = {name: "Steve", city: "New York"}; 2 | -------------------------------------------------------------------------------- /test/references-transform-library.d.ts: -------------------------------------------------------------------------------- 1 | declare var mylibrary : { 2 | mymethod : () => string; 3 | }; -------------------------------------------------------------------------------- /test/sourceroot/src/nested/b.html: -------------------------------------------------------------------------------- 1 |
Some content
2 | some other content -------------------------------------------------------------------------------- /test/sourceroot/src/nested/b.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | class B extends A {} -------------------------------------------------------------------------------- /test/templatecache/index.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/tsconfig/files/validtsconfig.ts: -------------------------------------------------------------------------------- 1 | var xyz = 'test'; 2 | // this is a comment. 3 | var abc = 123; 4 | -------------------------------------------------------------------------------- /test/htmlOutDirFlat/src/test.tpl.html: -------------------------------------------------------------------------------- 1 |
Some content
2 | some other content -------------------------------------------------------------------------------- /test/htmlTemplateGlob/othercompilation.ts: -------------------------------------------------------------------------------- 1 | const otherCompilation = 1; 2 | console.log(otherCompilation); 3 | -------------------------------------------------------------------------------- /test/amdtest/b.ts: -------------------------------------------------------------------------------- 1 | import C = require('c') 2 | class B extends C{ 3 | test = 123; 4 | } 5 | export = B; 6 | -------------------------------------------------------------------------------- /test/amdloader/ts/app/classa.ts: -------------------------------------------------------------------------------- 1 | class ClassA { 2 | constructor() { 3 | console.log('in A'); 4 | } 5 | } -------------------------------------------------------------------------------- /test/templatecache/ts/classa.ts: -------------------------------------------------------------------------------- 1 | class ClassA { 2 | constructor() { 3 | console.log('in a'); 4 | } 5 | } -------------------------------------------------------------------------------- /test/amdloader/ts/test/classt.ts: -------------------------------------------------------------------------------- 1 | class ClassT { 2 | constructor() { 3 | console.log('in T'); 4 | } 5 | } -------------------------------------------------------------------------------- /test/expected/noEmitOnError/testNoEmitOnError_false.js: -------------------------------------------------------------------------------- 1 | var x = 5; 2 | //# sourceMappingURL=testNoEmitOnError_false.js.map -------------------------------------------------------------------------------- /test/files_testFailedCompilation/a/syntaxError.ts: -------------------------------------------------------------------------------- 1 | class A { 2 | 3 | //intentional syntax error: missing close parenthesis -------------------------------------------------------------------------------- /test/htmlSnakeModuleName/src/snake-module-name.tpl.html: -------------------------------------------------------------------------------- 1 |
Some content
2 | some other content -------------------------------------------------------------------------------- /test/htmlTemplate/src/advanced.$$template.name.tpl.html: -------------------------------------------------------------------------------- 1 |
Some content
2 | some other content -------------------------------------------------------------------------------- /test/outdirtest/ts/source.ts: -------------------------------------------------------------------------------- 1 | module SomethingSimple { 2 | export function foo() { 3 | return "Ba Ba"; 4 | } 5 | } -------------------------------------------------------------------------------- /test/withwrongmodule/ts/Foo.ts: -------------------------------------------------------------------------------- 1 | class Foo { 2 | public bar():string { 3 | return 'Foo.bar'; 4 | } 5 | } 6 | 7 | export = Foo; -------------------------------------------------------------------------------- /test/expected/preserveConstEnums/test_preserveConstEnums_false.js: -------------------------------------------------------------------------------- 1 | var x = 1; 2 | //# sourceMappingURL=test_preserveConstEnums_false.js.map -------------------------------------------------------------------------------- /test/vsproj/vsprojtest1.ts: -------------------------------------------------------------------------------- 1 | 2 | //this came from file vsprojtest1.ts 3 | var insertThis = 'good'; 4 | var test1 = `test${insertThis}test`; -------------------------------------------------------------------------------- /test/allowJs/allowJsLibrary.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | function writeIt(value) { 3 | console.log(value); 4 | } 5 | exports.writeIt = writeIt; 6 | -------------------------------------------------------------------------------- /test/htmlExternal/html.external.html: -------------------------------------------------------------------------------- 1 |
2 | This is an HTML file that we want to compile to a TypeScript external module. 3 |
4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "10" 4 | - "8" 5 | - "6" 6 | - "4" 7 | before_script: 8 | - npm install -g grunt-cli 9 | -------------------------------------------------------------------------------- /test/templatecache/ts/app.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | var a = new ClassA 4 | var b = new ClassB 5 | var c = new ClassC 6 | -------------------------------------------------------------------------------- /test/transform/ts/foo/b/b2.ts: -------------------------------------------------------------------------------- 1 | 2 | import B1 = require('./b1'); 3 | 4 | export class B2 extends B1.B1 { 5 | b2() { return this.b1()+"b2" } 6 | } -------------------------------------------------------------------------------- /test/withemptymodule/ts/Main.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | class Main { 4 | constructor() { 5 | 6 | } 7 | } 8 | 9 | new Main(); -------------------------------------------------------------------------------- /test/work/work.ts: -------------------------------------------------------------------------------- 1 | module Simple1 { 2 | export function main() { 3 | return "hello simple1"; 4 | } 5 | } 6 | 7 | Simple1.main(); -------------------------------------------------------------------------------- /test/work/inside/work3.ts: -------------------------------------------------------------------------------- 1 | module Simple3 { 2 | export function main() { 3 | return "hello simple1"; 4 | } 5 | } 6 | 7 | Simple3.main(); -------------------------------------------------------------------------------- /test/expected/transform/ts/foo/b/b2.ts: -------------------------------------------------------------------------------- 1 | 2 | import B1 = require('./b1'); 3 | 4 | export class B2 extends B1.B1 { 5 | b2() { return this.b1()+"b2" } 6 | } -------------------------------------------------------------------------------- /test/fail/ts/deep/fail.ts: -------------------------------------------------------------------------------- 1 | module Simple1 { 2 | export function main() { 3 | return "hello simple1"; 4 | } 5 | } 6 | 7 | Simplebad.main(); 8 | -------------------------------------------------------------------------------- /test/tsconfig_artifact/extends/configs/base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "noImplicitAny": true, 4 | "strictNullChecks": true 5 | } 6 | } -------------------------------------------------------------------------------- /test/amdloader/ts/app/app.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | var a = new ClassA 4 | var b = new ClassB 5 | var c = new ClassC 6 | var d = new ClassD -------------------------------------------------------------------------------- /test/expected/es6/es6/stringTemplate.js: -------------------------------------------------------------------------------- 1 | { 2 | let name = "World"; 3 | console.log(`Hello ${name}!`); 4 | } 5 | //# sourceMappingURL=stringTemplate.js.map -------------------------------------------------------------------------------- /test/expected/vsproj/ignoreSettings/vsprojtest1.js: -------------------------------------------------------------------------------- 1 | var insertThis = 'good'; 2 | var test1 = `test${insertThis}test`; 3 | //# sourceMappingURL=vsprojtest1.js.map -------------------------------------------------------------------------------- /test/abtest/reference.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | //grunt-start 4 | /// 5 | //grunt-end 6 | 7 | /// -------------------------------------------------------------------------------- /test/htmlSnakeModuleName/src/foo.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | var boo = snakeModuleName.tpl_html_module.snakeModuleName_tpl_html_variable; 4 | -------------------------------------------------------------------------------- /test/nocompile/reference.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | //grunt-start 4 | /// 5 | //grunt-end 6 | 7 | /// -------------------------------------------------------------------------------- /test/transform/ts/foo/a/A2.ts: -------------------------------------------------------------------------------- 1 | 2 | import A1 = require('./A1'); 3 | 4 | class A2 extends A1 { 5 | a2() { return this.a1()+"a2" } 6 | } 7 | 8 | 9 | export = A2 -------------------------------------------------------------------------------- /test/tsconfig_artifact/extends/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./configs/base", 3 | "files": [ 4 | "../../abtest/a.ts", 5 | "../../abtest/b.ts" 6 | ] 7 | } -------------------------------------------------------------------------------- /test/tsconfig_artifact/extends/tsconfig.nostrictnull.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig", 3 | "compilerOptions": { 4 | "strictNullChecks": false 5 | } 6 | } -------------------------------------------------------------------------------- /test/expected/amdloader/js/app/loader.bin.js: -------------------------------------------------------------------------------- 1 | define(["./classa","./partials/templates.a.html","./deep/classb","./deep/classc","./deep/deeper/classd","./app"],function () {}); -------------------------------------------------------------------------------- /test/expected/es6/es5/stringTemplate.js: -------------------------------------------------------------------------------- 1 | { 2 | var name_1 = "World"; 3 | console.log("Hello " + name_1 + "!"); 4 | } 5 | //# sourceMappingURL=stringTemplate.js.map -------------------------------------------------------------------------------- /test/expected/transform/ts/foo/a/A2.ts: -------------------------------------------------------------------------------- 1 | 2 | import A1 = require('./A1'); 3 | 4 | class A2 extends A1 { 5 | a2() { return this.a1()+"a2" } 6 | } 7 | 8 | 9 | export = A2 -------------------------------------------------------------------------------- /test/htmlSnakeModuleName/reference.ts: -------------------------------------------------------------------------------- 1 | //grunt-start 2 | /// 3 | /// 4 | //grunt-end -------------------------------------------------------------------------------- /test/htmlTemplate/reference.ts: -------------------------------------------------------------------------------- 1 | //grunt-start 2 | /// 3 | /// 4 | //grunt-end -------------------------------------------------------------------------------- /test/multifile/a/reference.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | //grunt-start 4 | /// 5 | //grunt-end 6 | 7 | /// -------------------------------------------------------------------------------- /test/multifile/b/reference.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | //grunt-start 4 | /// 5 | //grunt-end 6 | 7 | /// -------------------------------------------------------------------------------- /test/referenceReplaced/referenced-grunt-ts.ts: -------------------------------------------------------------------------------- 1 | //grunt-start 2 | /// 3 | /// 4 | //grunt-end 5 | -------------------------------------------------------------------------------- /test/work/work2.ts: -------------------------------------------------------------------------------- 1 | module Simple2 { 2 | // Simple comment 3 | export function main() { 4 | return "hello simple1"; 5 | } 6 | } 7 | 8 | Simple2.main(); -------------------------------------------------------------------------------- /test/expected/abtest/reference.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | //grunt-start 4 | /// 5 | //grunt-end 6 | 7 | /// -------------------------------------------------------------------------------- /test/htmlTemplate/src/foo.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | var boo = advanced.$$template.name.tpl_html_module.advanced_$$template_name_tpl_html_variable; 4 | -------------------------------------------------------------------------------- /test/preserveConstEnums/test_preserveConstEnums.ts: -------------------------------------------------------------------------------- 1 | const enum Stuff { 2 | A = 0x1, 3 | B = 0x2, 4 | C = 0x4, 5 | All = A | B | C 6 | } 7 | 8 | var x: Stuff = Stuff.A; -------------------------------------------------------------------------------- /test/sourceroot/src/reference.ts: -------------------------------------------------------------------------------- 1 | //grunt-start 2 | /// 3 | /// 4 | /// 5 | //grunt-end -------------------------------------------------------------------------------- /test/transform/ts/foo/a/A1.ts: -------------------------------------------------------------------------------- 1 | ///ts:ref=A2 2 | /// ///ts:ref:generated 3 | 4 | class A1 { 5 | a1() { return "a1" } 6 | } 7 | 8 | 9 | export = A1 -------------------------------------------------------------------------------- /test/htmlOutDir/reference.ts: -------------------------------------------------------------------------------- 1 | //grunt-start 2 | /// 3 | /// 4 | /// 5 | //grunt-end -------------------------------------------------------------------------------- /test/customcompiler/ts/foo.ts: -------------------------------------------------------------------------------- 1 | // The old compiler would strip the trailing comma. Our custom build doesn't 2 | // So the output helps verify that a custom compiler was used 3 | var foo = [1, ]; -------------------------------------------------------------------------------- /test/expected/transform/ts/foo/a/A1.ts: -------------------------------------------------------------------------------- 1 | ///ts:ref=A2 2 | /// ///ts:ref:generated 3 | 4 | class A1 { 5 | a1() { return "a1" } 6 | } 7 | 8 | 9 | export = A1 -------------------------------------------------------------------------------- /test/htmlOutDirFlat/reference.ts: -------------------------------------------------------------------------------- 1 | //grunt-start 2 | /// 3 | /// 4 | /// 5 | //grunt-end -------------------------------------------------------------------------------- /test/issue_392_2/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "compiled" 4 | }, 5 | "exclude": [ 6 | "spec", 7 | "e2e", 8 | "node_modules" 9 | ] 10 | } -------------------------------------------------------------------------------- /test/expected/htmlExternal/html.external.html.ts: -------------------------------------------------------------------------------- 1 | module html.external { 2 | export var html = '
This is an HTML file that we want to compile to a TypeScript external module.
'; 3 | } 4 | -------------------------------------------------------------------------------- /test/amdloader/ts/test/test.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | var t = new ClassT 4 | var u = new ClassU 5 | var v = new ClassV 6 | var w = new ClassW 7 | 8 | var extended = new ExtendedAppCode -------------------------------------------------------------------------------- /test/withemptymodule/ts/Bar.ts: -------------------------------------------------------------------------------- 1 | class Bar { 2 | public value:string; 3 | 4 | constructor() { 5 | this.value = 'bar'; 6 | } 7 | 8 | public getValue() { 9 | return this.value; 10 | } 11 | } -------------------------------------------------------------------------------- /test/withemptymodule/ts/Foo.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | class Foo extends Bar { 4 | 5 | constructor() { 6 | super(); 7 | this.value = 'foo ' + this.value; 8 | } 9 | 10 | } -------------------------------------------------------------------------------- /test/templatecache/ts/deep/classc.ts: -------------------------------------------------------------------------------- 1 | /// 2 | class ClassC extends ClassA { 3 | constructor() { 4 | super(); 5 | console.log('class c'); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/amdloader/ts/app/deep/deeper/classd.ts: -------------------------------------------------------------------------------- 1 | /// 2 | class ClassD extends ClassC { 3 | constructor() { 4 | super(); 5 | console.log('class D'); 6 | } 7 | } -------------------------------------------------------------------------------- /test/amdloader/ts/test/deep/deeper/classw.ts: -------------------------------------------------------------------------------- 1 | /// 2 | class ClassW extends ClassV { 3 | constructor() { 4 | super(); 5 | console.log('class W'); 6 | } 7 | } -------------------------------------------------------------------------------- /test/suppressImplicitAnyIndexErrors/test_suppressImplicitAnyIndexError.ts: -------------------------------------------------------------------------------- 1 | interface person { 2 | name: string; 3 | } 4 | 5 | var p : person = { name: "Test" }; 6 | p["age"] = 101; 7 | console.log(p["age"]); 8 | -------------------------------------------------------------------------------- /test/templatecache/ts/deep/classb.ts: -------------------------------------------------------------------------------- 1 | /// 2 | class ClassB extends ClassA { 3 | constructor() { 4 | super(); 5 | console.log('class b'); 6 | } 7 | } 8 | 9 | -------------------------------------------------------------------------------- /test/references-transform/references-transform.ts: -------------------------------------------------------------------------------- 1 | ///ts:ref=references-transform-library 2 | /// ///ts:ref:generated 3 | 4 | var test : string = mylibrary.mymethod(); -------------------------------------------------------------------------------- /test/expected/suppressImplicitAnyIndexErrors/test_suppressImplicitAnyIndexError_true.js: -------------------------------------------------------------------------------- 1 | var p = { name: "Test" }; 2 | p["age"] = 101; 3 | console.log(p["age"]); 4 | //# sourceMappingURL=test_suppressImplicitAnyIndexError_true.js.map -------------------------------------------------------------------------------- /test/templatecache/ts/reference.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | //grunt-start 4 | /// 5 | /// 6 | //grunt-end 7 | 8 | /// -------------------------------------------------------------------------------- /test/tsconfig_artifact/invalid_tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.5.3", 3 | "compilerOptions": { 4 | "target": "es5", 5 | "module": "commonjs", 6 | "declaration": false, 7 | 8 | PURPOSEFULLY INVALID FILE. 9 | -------------------------------------------------------------------------------- /test/amdloader/ts/app/deep/classc.ts: -------------------------------------------------------------------------------- 1 | /// 2 | class ClassC extends ClassA { 3 | constructor() { 4 | super(); 5 | console.log('class C'); 6 | } 7 | } 8 | console.log('reading html:', templates.a.html); -------------------------------------------------------------------------------- /test/amdloader/ts/app/deep/classb.ts: -------------------------------------------------------------------------------- 1 | /// 2 | class ClassB extends ClassA { 3 | constructor() { 4 | super(); 5 | console.log('class B'); 6 | } 7 | } 8 | console.log('reading html:', templates.a.html); 9 | -------------------------------------------------------------------------------- /test/amdloader/ts/test/deep/classv.ts: -------------------------------------------------------------------------------- 1 | /// 2 | class ClassV extends ClassT { 3 | constructor() { 4 | super(); 5 | console.log('class V'); 6 | } 7 | } 8 | console.log('reading html:', templates.b.html); -------------------------------------------------------------------------------- /test/amdloader/ts/test/deep/classu.ts: -------------------------------------------------------------------------------- 1 | /// 2 | class ClassU extends ClassT { 3 | constructor() { 4 | super(); 5 | console.log('class U'); 6 | } 7 | } 8 | console.log('reading html:', templates.b.html); 9 | -------------------------------------------------------------------------------- /test/expected/references-transform/references-transform.js: -------------------------------------------------------------------------------- 1 | ///ts:ref=references-transform-library 2 | /// ///ts:ref:generated 3 | var test = mylibrary.mymethod(); 4 | //# sourceMappingURL=references-transform.js.map -------------------------------------------------------------------------------- /test/transform/ts/foo/a/index.ts: -------------------------------------------------------------------------------- 1 | ///ts:export=a 2 | import A1_file = require('./A1'); ///ts:export:generated 3 | export var A1 = A1_file; ///ts:export:generated 4 | import A2_file = require('./A2'); ///ts:export:generated 5 | export var A2 = A2_file; ///ts:export:generated -------------------------------------------------------------------------------- /defs/detect-newline/detect-newline.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for detect-newline 2 | // Project: https://github.com/sindresorhus/detect-newline 3 | declare module 'detect-newline' { 4 | var detectNewline: (string: string) => string; 5 | export = detectNewline; 6 | } 7 | -------------------------------------------------------------------------------- /test/expected/transform/ts/foo/a/index.ts: -------------------------------------------------------------------------------- 1 | ///ts:export=a 2 | import A1_file = require('./A1'); ///ts:export:generated 3 | export var A1 = A1_file; ///ts:export:generated 4 | import A2_file = require('./A2'); ///ts:export:generated 5 | export var A2 = A2_file; ///ts:export:generated -------------------------------------------------------------------------------- /test/fail/ts/deep/work.ts: -------------------------------------------------------------------------------- 1 | ///ts:import=nonexistent 2 | /// No file or directory matched name "nonexistent" ///ts:import:generated 3 | 4 | module Simple1 { 5 | export function main() { 6 | return "hello simple1"; 7 | } 8 | } 9 | 10 | Simple1.main(); 11 | -------------------------------------------------------------------------------- /test/expected/fail/ts/deep/work.ts: -------------------------------------------------------------------------------- 1 | ///ts:import=nonexistent 2 | /// No file or directory matched name "nonexistent" ///ts:import:generated 3 | 4 | module Simple1 { 5 | export function main() { 6 | return "hello simple1"; 7 | } 8 | } 9 | 10 | Simple1.main(); 11 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Basarat Ali Syed (http://www.basarat.com) 2 | Jeff May (https://github.com/jeffmay) 3 | Bart van der Schoor (https://github.com/Bartvds) 4 | Steve Ognibene (http://www.legendaryapps.com/) -------------------------------------------------------------------------------- /test/amdloader/ts/test/extendedAppCode.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | class ExtendedAppCode extends ClassA { 5 | constructor() { 6 | super(); 7 | console.log('External test class'); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /defs/detect-indent/detect-indent.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for detect-indent 2 | // Project: https://github.com/sindresorhus/detect-indent 3 | declare module 'detect-indent' { 4 | var detectIndent: (string: string) => { amount: number; type?: string; indent: string }; 5 | export = detectIndent; 6 | } 7 | -------------------------------------------------------------------------------- /test/expected/transform/js/foo/b/b1.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | exports.__esModule = true; 3 | var B1 = /** @class */ (function () { 4 | function B1() { 5 | } 6 | B1.prototype.b1 = function () { return "b1"; }; 7 | return B1; 8 | }()); 9 | exports.B1 = B1; 10 | //# sourceMappingURL=b1.js.map -------------------------------------------------------------------------------- /test/definitelytypedtest/test.ts: -------------------------------------------------------------------------------- 1 | // 2 | 3 | var callback = function(){ 4 | console.log('done'); 5 | } 6 | 7 | async.parallel([ 8 | function(){ console.log('hi'); }, 9 | function(){ console.log('there'); } 10 | ], callback); 11 | 12 | -------------------------------------------------------------------------------- /test/amdloader/ts/app/reference.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | //grunt-start 4 | /// 5 | /// 6 | /// 7 | //grunt-end 8 | 9 | /// 10 | /// -------------------------------------------------------------------------------- /test/expected/preserveConstEnums/test_preserveConstEnums_true.js: -------------------------------------------------------------------------------- 1 | var Stuff; 2 | (function (Stuff) { 3 | Stuff[Stuff["A"] = 1] = "A"; 4 | Stuff[Stuff["B"] = 2] = "B"; 5 | Stuff[Stuff["C"] = 4] = "C"; 6 | Stuff[Stuff["All"] = 7] = "All"; 7 | })(Stuff || (Stuff = {})); 8 | var x = 1; 9 | //# sourceMappingURL=test_preserveConstEnums_true.js.map -------------------------------------------------------------------------------- /test/expected/transform/js/foo/a/A1.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | ///ts:ref=A2 3 | /// ///ts:ref:generated 4 | var A1 = /** @class */ (function () { 5 | function A1() { 6 | } 7 | A1.prototype.a1 = function () { return "a1"; }; 8 | return A1; 9 | }()); 10 | module.exports = A1; 11 | //# sourceMappingURL=A1.js.map -------------------------------------------------------------------------------- /test/expected/transform/js/foo/a/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | exports.__esModule = true; 3 | ///ts:export=a 4 | var A1_file = require("./A1"); ///ts:export:generated 5 | exports.A1 = A1_file; ///ts:export:generated 6 | var A2_file = require("./A2"); ///ts:export:generated 7 | exports.A2 = A2_file; ///ts:export:generated 8 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /test/withwrongmodule/ts/Main.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import Foo = require("Foo"); 4 | 5 | class Main { 6 | 7 | private foo:Foo; 8 | 9 | constructor() { 10 | this.foo = new Foo(); 11 | } 12 | 13 | public init() { 14 | console.log(this.foo.bar) 15 | } 16 | } 17 | 18 | new Main().init(); 19 | 20 | export = Main; -------------------------------------------------------------------------------- /test/tsconfig_artifact/test_simple_with_out.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.5.3", 3 | "compilerOptions": { 4 | "target": "es6", 5 | "module": "amd", 6 | "out": "./files/this_is_the_out_file.js" 7 | }, 8 | "filesGlob": [ 9 | "./files/*.ts" 10 | ], 11 | "files": [ 12 | "./files/validtsconfig.ts" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /test/tsconfig_artifact/test_simple_with_outFile.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.5.3", 3 | "compilerOptions": { 4 | "target": "es6", 5 | "module": "amd", 6 | "outFile": "./files/this_is_the_outFile_file.js" 7 | }, 8 | "filesGlob": [ 9 | "./files/*.ts" 10 | ], 11 | "files": [ 12 | "./files/validtsconfig.ts" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /test/amdloader/ts/test/reference.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | //grunt-start 4 | /// 5 | /// 6 | /// 7 | /// 8 | //grunt-end 9 | 10 | /// 11 | /// -------------------------------------------------------------------------------- /test/expected/abtest/out.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"out.js","sourceRoot":"","sources":["c.ts","b.ts","a.ts","reference.ts"],"names":["C","C.constructor","B","B.constructor","A","A.constructor"],"mappings":"AAAA;IAAAA;;AAAWA,IAADA,SAACA;AAADA,CAACA,IAAA;;;;;;;ACAX,oCAAoC;AACpC;;IAAAE;;;AAAoBA,IAADA,SAACA;AAADA,CAACA,EAAJ,CAAC,EAAG;ACDpB,oCAAoC;AACpC;;IAAAE;;;AAAqBA,IAADA,SAACA;AAADA,CAACA,EAAL,CAAC,EAAI"} -------------------------------------------------------------------------------- /test/expected/templatecache/js/templateCache.js: -------------------------------------------------------------------------------- 1 | // You must have requirejs + text plugin loaded for this to work. 2 | define(["text!partials/test.html", 3 | "text!partials/test2.html"],function(test_html, 4 | test2_html){ 5 | angular.module("ng").run(["$templateCache",function($templateCache) { 6 | $templateCache.put("test.html", test_html); 7 | $templateCache.put("test2.html", test2_html); 8 | }]); 9 | }); -------------------------------------------------------------------------------- /test/expected/amdloader/js/app/loader.js: -------------------------------------------------------------------------------- 1 | define(function (require) { 2 | require(["./classa"],function (){ 3 | require([""],function (){ 4 | require(["./partials/templates.a.html", 5 | "./deep/classb", 6 | "./deep/classc"],function (){ 7 | require(["./deep/deeper/classd"],function (){ 8 | require(["./app"],function (){ 9 | 10 | }); 11 | }); 12 | }); 13 | }); 14 | }); 15 | }); -------------------------------------------------------------------------------- /test/expected/transform/js/rootLevel.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // TEST Process: 3 | // delete a generated lines 4 | //// Now compile and see if they reappear 5 | exports.__esModule = true; 6 | ///ts:import=nonexistent 7 | /// No file or directory matched name "nonexistent" ///ts:import:generated 8 | ///ts:someunknowntransform 9 | /// Unknown transform ///ts:unknown:generated 10 | //# sourceMappingURL=rootLevel.js.map -------------------------------------------------------------------------------- /test/simple/js/zoo.d.ts: -------------------------------------------------------------------------------- 1 | declare class Animal { 2 | name: string; 3 | constructor(name: string); 4 | move(meters: number): void; 5 | } 6 | declare class Snake extends Animal { 7 | constructor(name: string); 8 | move(): void; 9 | } 10 | declare class Horse extends Animal { 11 | constructor(name: string); 12 | move(): void; 13 | } 14 | declare var sam: Snake; 15 | declare var tom: Animal; 16 | -------------------------------------------------------------------------------- /defs/tsd.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | /// 5 | /// 6 | /// 7 | /// 8 | /// 9 | -------------------------------------------------------------------------------- /test/expected/simple/js/zoo.d.ts: -------------------------------------------------------------------------------- 1 | declare class Animal { 2 | name: string; 3 | constructor(name: string); 4 | move(meters: number): void; 5 | } 6 | declare class Snake extends Animal { 7 | constructor(name: string); 8 | move(): void; 9 | } 10 | declare class Horse extends Animal { 11 | constructor(name: string); 12 | move(): void; 13 | } 14 | declare var sam: Snake; 15 | declare var tom: Animal; 16 | -------------------------------------------------------------------------------- /test/issue_426_baseUrl/src/issue_426_1.tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "rootDir": "backend", 7 | "outDir": "dist", 8 | "baseUrl": ".", 9 | "lib": [ 10 | "es2017" 11 | ], 12 | "experimentalDecorators": true, 13 | "sourceMap": false 14 | }, 15 | "include": [ 16 | "app/**/*.ts" 17 | ] 18 | } -------------------------------------------------------------------------------- /test/issue_426_baseUrl/src/issue_426_2.tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "rootDir": "backend", 7 | "outDir": "dist", 8 | "baseUrl": "./", 9 | "lib": [ 10 | "es2017" 11 | ], 12 | "experimentalDecorators": true, 13 | "sourceMap": false 14 | }, 15 | "include": [ 16 | "app/**/*.ts" 17 | ] 18 | } -------------------------------------------------------------------------------- /test/issue_426_baseUrl/src/issue_426_3.tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "rootDir": "backend", 7 | "outDir": "dist", 8 | "baseUrl": "./app", 9 | "lib": [ 10 | "es2017" 11 | ], 12 | "experimentalDecorators": true, 13 | "sourceMap": false 14 | }, 15 | "include": [ 16 | "app/**/*.ts" 17 | ] 18 | } -------------------------------------------------------------------------------- /test/tsconfig_artifact/tsconfig-grunt-ts.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.5.3", 3 | "compilerOptions": { 4 | "target": "es5", 5 | "module": "commonjs", 6 | "declaration": false, 7 | "noImplicitAny": false, 8 | "removeComments": false, 9 | "noLib": false, 10 | "preserveConstEnums": false, 11 | "suppressImplicitAnyIndexErrors": true, 12 | "sourceMap": true 13 | }, 14 | "files": [] 15 | } 16 | -------------------------------------------------------------------------------- /test/issue_392/issue_392-tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "system", 5 | "moduleResolution": "node", 6 | "sourceMap": true, 7 | "emitDecoratorMetadata": true, 8 | "experimentalDecorators": true, 9 | "removeComments": false, 10 | "noImplicitAny": true, 11 | "suppressImplicitAnyIndexErrors": true 12 | }, 13 | "exclude": [ 14 | "spec", 15 | "e2e", 16 | "node_modules" 17 | ] 18 | } -------------------------------------------------------------------------------- /test/issue_397/src/issue_397-tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "system", 5 | "moduleResolution": "node", 6 | "sourceMap": true, 7 | "emitDecoratorMetadata": true, 8 | "experimentalDecorators": true, 9 | "removeComments": false, 10 | "noImplicitAny": true, 11 | "suppressImplicitAnyIndexErrors": true, 12 | "typeRoots": ["./typings", "./other_typings"] 13 | }, 14 | "files": ["app/397-a.ts"] 15 | } -------------------------------------------------------------------------------- /test/tsconfig_artifact/tab_indent_tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.5.3", 3 | "compilerOptions": { 4 | "target": "es6", 5 | "module": "amd", 6 | "declaration": true, 7 | "noImplicitAny": true, 8 | "removeComments": false, 9 | "noLib": true, 10 | "preserveConstEnums": false, 11 | "suppressImplicitAnyIndexErrors": true, 12 | "sourceMap": false, 13 | "inlineSourceMap": true, 14 | "inlineSources": true, 15 | "emitDecoratorMetadata": true, 16 | "experimentalDecorators": true 17 | }, 18 | "filesGlob": [ 19 | "./**/*.ts" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | 4 | .gitignore 5 | .gitattributes 6 | .npmignore 7 | 8 | /vsproj_test_config 9 | /test 10 | /customcompiler 11 | /.idea 12 | /defs 13 | /sample 14 | /tasks/scratch.* 15 | /tasks-internal 16 | /.tscache 17 | 18 | /tslint.json 19 | /tsd.json 20 | /tsconfig.json 21 | 22 | /.travis.yml 23 | /.jshintrc 24 | /Gruntfile.js 25 | /build.bat 26 | /*.tgz 27 | 28 | /tscommand*.tmp.txt 29 | 30 | /docs 31 | /AUTHORS 32 | /*.md 33 | /custom.TypeScript.targets 34 | 35 | /bin 36 | /obj 37 | /.vscode 38 | *.user 39 | *.suo 40 | *.csproj 41 | *.sln -------------------------------------------------------------------------------- /test/transform/ts/foo/index.ts: -------------------------------------------------------------------------------- 1 | ///ts:export=foo 2 | import A1_file = require('./a/A1'); ///ts:export:generated 3 | export var A1 = A1_file; ///ts:export:generated 4 | import A2_file = require('./a/A2'); ///ts:export:generated 5 | export var A2 = A2_file; ///ts:export:generated 6 | import a_file = require('./a/index'); ///ts:export:generated 7 | export var a = a_file; ///ts:export:generated 8 | import b1_file = require('./b/b1'); ///ts:export:generated 9 | export var b1 = b1_file; ///ts:export:generated 10 | import b2_file = require('./b/b2'); ///ts:export:generated 11 | export var b2 = b2_file; ///ts:export:generated -------------------------------------------------------------------------------- /test/expected/transform/ts/foo/index.ts: -------------------------------------------------------------------------------- 1 | ///ts:export=foo 2 | import A1_file = require('./a/A1'); ///ts:export:generated 3 | export var A1 = A1_file; ///ts:export:generated 4 | import A2_file = require('./a/A2'); ///ts:export:generated 5 | export var A2 = A2_file; ///ts:export:generated 6 | import a_file = require('./a/index'); ///ts:export:generated 7 | export var a = a_file; ///ts:export:generated 8 | import b1_file = require('./b/b1'); ///ts:export:generated 9 | export var b1 = b1_file; ///ts:export:generated 10 | import b2_file = require('./b/b2'); ///ts:export:generated 11 | export var b2 = b2_file; ///ts:export:generated -------------------------------------------------------------------------------- /test/tsconfig_artifact/three_spaces_indent_tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.5.3", 3 | "compilerOptions": { 4 | "target": "es6", 5 | "module": "amd", 6 | "declaration": true, 7 | "noImplicitAny": true, 8 | "removeComments": false, 9 | "noLib": true, 10 | "preserveConstEnums": false, 11 | "suppressImplicitAnyIndexErrors": true, 12 | "sourceMap": false, 13 | "inlineSourceMap": true, 14 | "inlineSources": true, 15 | "emitDecoratorMetadata": true, 16 | "experimentalDecorators": true 17 | }, 18 | "filesGlob": [ 19 | "./**/*.ts" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /test/tsconfig_artifact/test_include_wildcard.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.5.3", 3 | "compilerOptions": { 4 | "target": "es6", 5 | "module": "amd", 6 | "declaration": true, 7 | "noImplicitAny": true, 8 | "removeComments": false, 9 | "noLib": true, 10 | "preserveConstEnums": false, 11 | "suppressImplicitAnyIndexErrors": true, 12 | "sourceMap": false, 13 | "inlineSourceMap": true, 14 | "inlineSources": true, 15 | "emitDecoratorMetadata": true, 16 | "experimentalDecorators": true 17 | }, 18 | "include": [ 19 | "../../tasks/*" 20 | ] 21 | } -------------------------------------------------------------------------------- /test/tsconfig_artifact/four_spaces_indent_tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.5.3", 3 | "compilerOptions": { 4 | "target": "es6", 5 | "module": "amd", 6 | "declaration": true, 7 | "noImplicitAny": true, 8 | "removeComments": false, 9 | "noLib": true, 10 | "preserveConstEnums": false, 11 | "suppressImplicitAnyIndexErrors": true, 12 | "sourceMap": false, 13 | "inlineSourceMap": true, 14 | "inlineSources": true, 15 | "emitDecoratorMetadata": true, 16 | "experimentalDecorators": true 17 | }, 18 | "filesGlob": [ 19 | "./**/*.ts" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /test/tsconfig_artifact/mixed_indent_tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.5.3", 3 | "compilerOptions": { 4 | "target": "es6", 5 | "module": "amd", 6 | "declaration": true, 7 | "noImplicitAny": true, 8 | "removeComments": false, 9 | "noLib": true, 10 | "preserveConstEnums": false, 11 | "suppressImplicitAnyIndexErrors": true, 12 | "sourceMap": false, 13 | "inlineSourceMap": true, 14 | "inlineSources": true, 15 | "emitDecoratorMetadata": true, 16 | "experimentalDecorators": true 17 | }, 18 | "filesGlob": [ 19 | "./**/*.ts" 20 | ], 21 | "atom": { 22 | "rewriteTsConfig": false 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/tsconfig_artifact/simple_filesGlob_tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.5.3", 3 | "compilerOptions": { 4 | "target": "es6", 5 | "module": "amd", 6 | "declaration": true, 7 | "noImplicitAny": true, 8 | "removeComments": false, 9 | "noLib": true, 10 | "preserveConstEnums": false, 11 | "suppressImplicitAnyIndexErrors": true, 12 | "sourceMap": false, 13 | "inlineSourceMap": true, 14 | "inlineSources": true, 15 | "emitDecoratorMetadata": true, 16 | "experimentalDecorators": true 17 | }, 18 | "filesGlob": [ 19 | "./**/*.ts" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /test/expected/allowJs/result.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | function writeIt(value) { 3 | console.log(value); 4 | } 5 | exports.writeIt = writeIt; 6 | System.register("allowJsConsumer", ["allowJsLibrary"], function (exports_1, context_1) { 7 | "use strict"; 8 | var allowJsLibrary_1; 9 | var __moduleName = context_1 && context_1.id; 10 | return { 11 | setters: [ 12 | function (allowJsLibrary_1_1) { 13 | allowJsLibrary_1 = allowJsLibrary_1_1; 14 | } 15 | ], 16 | execute: function () { 17 | allowJsLibrary_1.writeIt("test"); 18 | } 19 | }; 20 | }); 21 | //# sourceMappingURL=result.js.map -------------------------------------------------------------------------------- /test/expected/transform/js/foo/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | exports.__esModule = true; 3 | ///ts:export=foo 4 | var A1_file = require("./a/A1"); ///ts:export:generated 5 | exports.A1 = A1_file; ///ts:export:generated 6 | var A2_file = require("./a/A2"); ///ts:export:generated 7 | exports.A2 = A2_file; ///ts:export:generated 8 | var a_file = require("./a/index"); ///ts:export:generated 9 | exports.a = a_file; ///ts:export:generated 10 | var b1_file = require("./b/b1"); ///ts:export:generated 11 | exports.b1 = b1_file; ///ts:export:generated 12 | var b2_file = require("./b/b2"); ///ts:export:generated 13 | exports.b2 = b2_file; ///ts:export:generated 14 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /test/transform/ts/bar/c/c1.ts: -------------------------------------------------------------------------------- 1 | ///ts:import=foo 2 | import foo = require('../../foo/index'); ///ts:import:generated 3 | 4 | // USE CLASSES FROM A/B: 5 | 6 | // With `export =` and naming file same as main export variable: 7 | var a1 = new foo.A1(); 8 | var a2 = new foo.A2(); 9 | 10 | // Conventional javascript file naming and exporting class with `export class ClassName` 11 | var B1 = foo.b1.B1; 12 | var B2 = foo.b2.B2; 13 | var b1Instance = new B1(); 14 | var b2Instance = new B2(); 15 | 16 | 17 | // Tests: 18 | 19 | console.log(a1.a1()); 20 | console.log(a2.a2()); 21 | 22 | console.log(b1Instance.b1()); 23 | console.log(b2Instance.b2()); 24 | 25 | console.log('executed c'); -------------------------------------------------------------------------------- /custom.TypeScript.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | {d4683cae-88c4-4b85-863d-ac8014f3ba36} 4 | {d4683cae-88c4-4b85-863d-ac8014f3ba36} 5 | {d4683cae-88c4-4b85-863d-ac8014f3ba36} 6 | 7 | 8 | 9 | 10 | 11 | true 12 | 13 | -------------------------------------------------------------------------------- /test/expected/transform/ts/bar/c/c1.ts: -------------------------------------------------------------------------------- 1 | ///ts:import=foo 2 | import foo = require('../../foo/index'); ///ts:import:generated 3 | 4 | // USE CLASSES FROM A/B: 5 | 6 | // With `export =` and naming file same as main export variable: 7 | var a1 = new foo.A1(); 8 | var a2 = new foo.A2(); 9 | 10 | // Conventional javascript file naming and exporting class with `export class ClassName` 11 | var B1 = foo.b1.B1; 12 | var B2 = foo.b2.B2; 13 | var b1Instance = new B1(); 14 | var b2Instance = new B2(); 15 | 16 | 17 | // Tests: 18 | 19 | console.log(a1.a1()); 20 | console.log(a2.a2()); 21 | 22 | console.log(b1Instance.b1()); 23 | console.log(b2Instance.b2()); 24 | 25 | console.log('executed c'); -------------------------------------------------------------------------------- /test/tsconfig_artifact/test_exclude_tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.5.3", 3 | "compilerOptions": { 4 | "target": "es6", 5 | "module": "amd", 6 | "declaration": true, 7 | "noImplicitAny": true, 8 | "removeComments": false, 9 | "noLib": true, 10 | "preserveConstEnums": false, 11 | "suppressImplicitAnyIndexErrors": true, 12 | "sourceMap": false, 13 | "inlineSourceMap": true, 14 | "inlineSources": true, 15 | "emitDecoratorMetadata": true, 16 | "experimentalDecorators": true 17 | }, 18 | "exclude": [ 19 | "./files", 20 | "./otherFiles/this.ts" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /test/tsconfig_artifact/test_include_tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.5.3", 3 | "compilerOptions": { 4 | "target": "es6", 5 | "module": "amd", 6 | "declaration": true, 7 | "noImplicitAny": true, 8 | "removeComments": false, 9 | "noLib": true, 10 | "preserveConstEnums": false, 11 | "suppressImplicitAnyIndexErrors": true, 12 | "sourceMap": false, 13 | "inlineSourceMap": true, 14 | "inlineSources": true, 15 | "emitDecoratorMetadata": true, 16 | "experimentalDecorators": true 17 | }, 18 | "include": [ 19 | "../abtest/**/*.ts", 20 | "../customcompiler/**/*.ts" 21 | ] 22 | } -------------------------------------------------------------------------------- /test/failontypeerror/ts/fail.ts: -------------------------------------------------------------------------------- 1 | // Error code 1 due to explicit type error 2 | /*var a: string = '', 3 | b: number = a + 2; 4 | 5 | console.log(b);*/ 6 | 7 | // Error code 4 due to accessing private member 8 | 9 | export class TestClass1 { 10 | public publicMember: PrivateInterface; 11 | 12 | constructor() { 13 | this.publicMember = {a: 1, b: 2}; 14 | console.log(this.publicMember.b); 15 | } 16 | } 17 | 18 | export class TestClass2 { 19 | constructor(t: TestClass1) { 20 | var m: PrivateInterface = t.publicMember; // Accessing private interface 21 | console.log(m.b); 22 | } 23 | } 24 | 25 | interface PrivateInterface { 26 | a: number; 27 | } 28 | -------------------------------------------------------------------------------- /test/simple/ts/zoo.ts: -------------------------------------------------------------------------------- 1 | class Animal { 2 | constructor(public name: string) { } 3 | move(meters: number) { 4 | alert(this.name + " moved " + meters + "m."); 5 | } 6 | } 7 | 8 | class Snake extends Animal { 9 | constructor(name: string) { super(name); } 10 | move() { 11 | alert("Slithering..."); 12 | super.move(5); 13 | } 14 | } 15 | 16 | class Horse extends Animal { 17 | constructor(name: string) { super(name); } 18 | move() { 19 | alert("Galloping..."); 20 | super.move(45); 21 | } 22 | } 23 | 24 | var sam = new Snake("Sammy the Python"); 25 | var tom: Animal = new Horse("Tommy the Palomino"); 26 | 27 | sam.move(); 28 | tom.move(34); 29 | -------------------------------------------------------------------------------- /test/tsconfig_artifact/tab_indent_tsconfig.expected.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.5.3", 3 | "compilerOptions": { 4 | "target": "es6", 5 | "module": "amd", 6 | "declaration": true, 7 | "noImplicitAny": true, 8 | "removeComments": false, 9 | "noLib": true, 10 | "preserveConstEnums": false, 11 | "suppressImplicitAnyIndexErrors": true, 12 | "sourceMap": false, 13 | "inlineSourceMap": true, 14 | "inlineSources": true, 15 | "emitDecoratorMetadata": true, 16 | "experimentalDecorators": true 17 | }, 18 | "filesGlob": [ 19 | "./**/*.ts" 20 | ], 21 | "files": [ 22 | "files/validtsconfig.ts", 23 | "otherFiles/other.ts", 24 | "otherFiles/that.ts", 25 | "otherFiles/this.ts" 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /test/expected/transform/js/bar/c/c1.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | exports.__esModule = true; 3 | ///ts:import=foo 4 | var foo = require("../../foo/index"); ///ts:import:generated 5 | // USE CLASSES FROM A/B: 6 | // With `export =` and naming file same as main export variable: 7 | var a1 = new foo.A1(); 8 | var a2 = new foo.A2(); 9 | // Conventional javascript file naming and exporting class with `export class ClassName` 10 | var B1 = foo.b1.B1; 11 | var B2 = foo.b2.B2; 12 | var b1Instance = new B1(); 13 | var b2Instance = new B2(); 14 | // Tests: 15 | console.log(a1.a1()); 16 | console.log(a2.a2()); 17 | console.log(b1Instance.b1()); 18 | console.log(b2Instance.b2()); 19 | console.log('executed c'); 20 | //# sourceMappingURL=c1.js.map -------------------------------------------------------------------------------- /test/tsconfig_artifact/test_simple_tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.5.3", 3 | "compilerOptions": { 4 | "target": "es6", 5 | "module": "amd", 6 | "declaration": true, 7 | "noImplicitAny": true, 8 | "removeComments": false, 9 | "noLib": true, 10 | "preserveConstEnums": false, 11 | "suppressImplicitAnyIndexErrors": true, 12 | "sourceMap": false, 13 | "inlineSourceMap": true, 14 | "inlineSources": true, 15 | "emitDecoratorMetadata": true, 16 | "experimentalDecorators": true 17 | }, 18 | "files": [ 19 | "./files/validtsconfig.ts" 20 | ], 21 | "exclude": [ 22 | "./files" 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /test/tsconfig_artifact/newlineConfigs/lf_newline_tsconfig.json.ts: -------------------------------------------------------------------------------- 1 | export const lf_newline_tsconfig_json = 2 | '{\n' + 3 | ' "version": "1.5.3",\n' + 4 | ' "compilerOptions": {\n' + 5 | ' "target": "es6",\n' + 6 | ' "module": "amd",\n' + 7 | ' "declaration": true,\n' + 8 | ' "noImplicitAny": true,\n' + 9 | ' "removeComments": false,\n' + 10 | ' "noLib": true,\n' + 11 | ' "preserveConstEnums": false,\n' + 12 | ' "suppressImplicitAnyIndexErrors": true,\n' + 13 | ' "sourceMap": false,\n' + 14 | ' "inlineSourceMap": true,\n' + 15 | ' "inlineSources": true,\n' + 16 | ' "emitDecoratorMetadata": true,\n' + 17 | ' "experimentalDecorators": true\n' + 18 | ' },\n' + 19 | ' "filesGlob": [\n' + 20 | ' "./**/*.ts"\n' + 21 | ' ]\n' + 22 | '}\n' 23 | -------------------------------------------------------------------------------- /sample/commonjs/Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function (grunt) { 2 | 'use strict'; 3 | 4 | // Change this 5 | var srcDir = 'lib'; 6 | 7 | grunt.initConfig({ 8 | ts: { 9 | options: { 10 | target: 'es5', 11 | module: 'commonjs', 12 | sourceMap: false, 13 | }, 14 | dev: { 15 | src: [srcDir + '/**/*.ts'], 16 | watch: srcDir 17 | }, 18 | build: { 19 | src: [srcDir + '/**/*.ts'], 20 | }, 21 | }, 22 | }); 23 | 24 | grunt.loadNpmTasks('grunt-ts'); 25 | grunt.registerTask('default', ['ts:dev']); 26 | grunt.registerTask('build', ['ts:build']); 27 | }; 28 | -------------------------------------------------------------------------------- /test/expected/htmlSnakeModuleName/out.js: -------------------------------------------------------------------------------- 1 | /* tslint:disable:max-line-length */ 2 | var snakeModuleName; 3 | (function (snakeModuleName) { 4 | var tpl_html_module; 5 | (function (tpl_html_module) { 6 | tpl_html_module.snakeModuleName_tpl_html_variable = '
Some content
some other content '; 7 | })(tpl_html_module = snakeModuleName.tpl_html_module || (snakeModuleName.tpl_html_module = {})); 8 | })(snakeModuleName || (snakeModuleName = {})); 9 | /// 10 | var boo = snakeModuleName.tpl_html_module.snakeModuleName_tpl_html_variable; 11 | //grunt-start 12 | /// 13 | /// 14 | //grunt-end 15 | //# sourceMappingURL=out.js.map -------------------------------------------------------------------------------- /test/transform/ts/bar/c/c2.ts: -------------------------------------------------------------------------------- 1 | ///ts:import=a 2 | import a = require('../../foo/a/index'); ///ts:import:generated 3 | ///ts:import=b1 4 | import b1 = require('../../foo/b/b1'); ///ts:import:generated 5 | ///ts:import=b2 6 | import b2 = require('../../foo/b/b2'); ///ts:import:generated 7 | 8 | // USE CLASSES FROM A/B: 9 | 10 | // With `export =` and naming file same as main export variable: 11 | var a1 = new a.A1(); 12 | var a2 = new a.A2(); 13 | 14 | // Conventional javascript file naming and exporting class with `export class ClassName` 15 | var b1Instance = new b1.B1(); 16 | var b2Instance = new b2.B2(); 17 | 18 | // Tests: 19 | console.log(a1.a1()); 20 | console.log(a2.a2()); 21 | 22 | console.log(b1Instance.b1()); 23 | console.log(b2Instance.b2()); 24 | 25 | console.log('executed c'); -------------------------------------------------------------------------------- /test/expected/transform/ts/bar/c/c2.ts: -------------------------------------------------------------------------------- 1 | ///ts:import=a 2 | import a = require('../../foo/a/index'); ///ts:import:generated 3 | ///ts:import=b1 4 | import b1 = require('../../foo/b/b1'); ///ts:import:generated 5 | ///ts:import=b2 6 | import b2 = require('../../foo/b/b2'); ///ts:import:generated 7 | 8 | // USE CLASSES FROM A/B: 9 | 10 | // With `export =` and naming file same as main export variable: 11 | var a1 = new a.A1(); 12 | var a2 = new a.A2(); 13 | 14 | // Conventional javascript file naming and exporting class with `export class ClassName` 15 | var b1Instance = new b1.B1(); 16 | var b2Instance = new b2.B2(); 17 | 18 | // Tests: 19 | console.log(a1.a1()); 20 | console.log(a2.a2()); 21 | 22 | console.log(b1Instance.b1()); 23 | console.log(b2Instance.b2()); 24 | 25 | console.log('executed c'); -------------------------------------------------------------------------------- /test/tsconfig_artifact/three_spaces_indent_tsconfig.expected.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.5.3", 3 | "compilerOptions": { 4 | "target": "es6", 5 | "module": "amd", 6 | "declaration": true, 7 | "noImplicitAny": true, 8 | "removeComments": false, 9 | "noLib": true, 10 | "preserveConstEnums": false, 11 | "suppressImplicitAnyIndexErrors": true, 12 | "sourceMap": false, 13 | "inlineSourceMap": true, 14 | "inlineSources": true, 15 | "emitDecoratorMetadata": true, 16 | "experimentalDecorators": true 17 | }, 18 | "filesGlob": [ 19 | "./**/*.ts" 20 | ], 21 | "files": [ 22 | "files/validtsconfig.ts", 23 | "otherFiles/other.ts", 24 | "otherFiles/that.ts", 25 | "otherFiles/this.ts" 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /test/tsconfig_artifact/mixed_indent_tsconfig.expected.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.5.3", 3 | "compilerOptions": { 4 | "target": "es6", 5 | "module": "amd", 6 | "declaration": true, 7 | "noImplicitAny": true, 8 | "removeComments": false, 9 | "noLib": true, 10 | "preserveConstEnums": false, 11 | "suppressImplicitAnyIndexErrors": true, 12 | "sourceMap": false, 13 | "inlineSourceMap": true, 14 | "inlineSources": true, 15 | "emitDecoratorMetadata": true, 16 | "experimentalDecorators": true 17 | }, 18 | "filesGlob": [ 19 | "./**/*.ts" 20 | ], 21 | "atom": { 22 | "rewriteTsConfig": false 23 | }, 24 | "files": [ 25 | "files/validtsconfig.ts", 26 | "otherFiles/other.ts", 27 | "otherFiles/that.ts", 28 | "otherFiles/this.ts" 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | test/tmp 4 | /.idea 5 | /*.tgz 6 | *.iml 7 | tasks/*.js 8 | test/out.d.ts 9 | test/work/out.d.ts 10 | test/work/reference.ts 11 | *.map 12 | test/**/*.js 13 | test/**/*.html.ts 14 | !test/expected/htmlExternal/*.ts 15 | test/html/reference.ts 16 | !test/allowJs/allowJsLibrary.js 17 | 18 | test/definitelytypedtest/reference.ts 19 | /tscommand*.tmp.txt 20 | 21 | !.gitignore 22 | !tasks/ts.js 23 | !tasks/ts-internal.js 24 | !test/expected/**/*.js 25 | !test/expected/**/*.map 26 | !test/tsconfig_artifact/newlineConfigs/*.js 27 | !test/commandLineAssertions.js 28 | !test/optionsResolverTests.js 29 | !test/compilerTests.js 30 | !test/testHelpers.js 31 | .tscache/ 32 | !test/tsconfig/*.json 33 | bin/ 34 | obj/ 35 | *.user 36 | *.suo 37 | .project 38 | .settings/ 39 | /.vs 40 | /.alm/ 41 | -------------------------------------------------------------------------------- /test/expected/transform/js/bar/c/c2.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | exports.__esModule = true; 3 | ///ts:import=a 4 | var a = require("../../foo/a/index"); ///ts:import:generated 5 | ///ts:import=b1 6 | var b1 = require("../../foo/b/b1"); ///ts:import:generated 7 | ///ts:import=b2 8 | var b2 = require("../../foo/b/b2"); ///ts:import:generated 9 | // USE CLASSES FROM A/B: 10 | // With `export =` and naming file same as main export variable: 11 | var a1 = new a.A1(); 12 | var a2 = new a.A2(); 13 | // Conventional javascript file naming and exporting class with `export class ClassName` 14 | var b1Instance = new b1.B1(); 15 | var b2Instance = new b2.B2(); 16 | // Tests: 17 | console.log(a1.a1()); 18 | console.log(a2.a2()); 19 | console.log(b1Instance.b1()); 20 | console.log(b2Instance.b2()); 21 | console.log('executed c'); 22 | //# sourceMappingURL=c2.js.map -------------------------------------------------------------------------------- /test/tsconfig_artifact/four_spaces_indent_tsconfig.expected.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.5.3", 3 | "compilerOptions": { 4 | "target": "es6", 5 | "module": "amd", 6 | "declaration": true, 7 | "noImplicitAny": true, 8 | "removeComments": false, 9 | "noLib": true, 10 | "preserveConstEnums": false, 11 | "suppressImplicitAnyIndexErrors": true, 12 | "sourceMap": false, 13 | "inlineSourceMap": true, 14 | "inlineSources": true, 15 | "emitDecoratorMetadata": true, 16 | "experimentalDecorators": true 17 | }, 18 | "filesGlob": [ 19 | "./**/*.ts" 20 | ], 21 | "files": [ 22 | "files/validtsconfig.ts", 23 | "otherFiles/other.ts", 24 | "otherFiles/that.ts", 25 | "otherFiles/this.ts" 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /tsd.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "v4", 3 | "repo": "DefinitelyTyped/DefinitelyTyped", 4 | "ref": "master", 5 | "path": "defs", 6 | "bundle": "defs/tsd.d.ts", 7 | "installed": { 8 | "node/node.d.ts": { 9 | "commit": "7f5ba75603de7e6c5b1d24125518220c1f5ecd84" 10 | }, 11 | "gruntjs/gruntjs.d.ts": { 12 | "commit": "7f5ba75603de7e6c5b1d24125518220c1f5ecd84" 13 | }, 14 | "nodeunit/nodeunit.d.ts": { 15 | "commit": "7f5ba75603de7e6c5b1d24125518220c1f5ecd84" 16 | }, 17 | "es6-promise/es6-promise.d.ts": { 18 | "commit": "7f5ba75603de7e6c5b1d24125518220c1f5ecd84" 19 | }, 20 | "semver/semver.d.ts": { 21 | "commit": "7f5ba75603de7e6c5b1d24125518220c1f5ecd84" 22 | }, 23 | "lodash/lodash.d.ts": { 24 | "commit": "de82425735f84a10b43921ae4b1d085b3752a626" 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /test/tsconfig_artifact/newlineConfigs/mixed_newline_tsconfig.json.ts: -------------------------------------------------------------------------------- 1 | export const mixed_newline_tsconfig_json = 2 | '{\r\n' + 3 | ' "version": "1.5.3",\r\n' + 4 | ' "compilerOptions": {\r\n' + 5 | ' "target": "es6",\n' + 6 | ' "module": "amd",\n' + 7 | ' "declaration": true,\n' + 8 | ' "noImplicitAny": true,\r\n' + 9 | ' "removeComments": false,\n' + 10 | ' "noLib": true,\n' + 11 | ' "preserveConstEnums": false,\n' + 12 | ' "suppressImplicitAnyIndexErrors": true,\n' + 13 | ' "sourceMap": false,\n' + 14 | ' "inlineSourceMap": true,\n' + 15 | ' "inlineSources": true,\n' + 16 | ' "emitDecoratorMetadata": true,\n' + 17 | ' "experimentalDecorators": true\n' + 18 | ' },\n' + 19 | ' "filesGlob": [\r\n' + 20 | ' "./**/*.ts"\r\n' + 21 | ' ]\n' + 22 | '}\r\n' 23 | -------------------------------------------------------------------------------- /test/tsconfig_artifact/newlineConfigs/crlf_newline_tsconfig.json.ts: -------------------------------------------------------------------------------- 1 | export const crlf_newline_tsconfig_json = 2 | '{\r\n' + 3 | ' "version": "1.5.3",\r\n' + 4 | ' "compilerOptions": {\r\n' + 5 | ' "target": "es6",\r\n' + 6 | ' "module": "amd",\r\n' + 7 | ' "declaration": true,\r\n' + 8 | ' "noImplicitAny": true,\r\n' + 9 | ' "removeComments": false,\r\n' + 10 | ' "noLib": true,\r\n' + 11 | ' "preserveConstEnums": false,\r\n' + 12 | ' "suppressImplicitAnyIndexErrors": true,\r\n' + 13 | ' "sourceMap": false,\r\n' + 14 | ' "inlineSourceMap": true,\r\n' + 15 | ' "inlineSources": true,\r\n' + 16 | ' "emitDecoratorMetadata": true,\r\n' + 17 | ' "experimentalDecorators": true\r\n' + 18 | ' },\r\n' + 19 | ' "filesGlob": [\r\n' + 20 | ' "./**/*.ts"\r\n' + 21 | ' ]\r\n' + 22 | '}\r\n' 23 | -------------------------------------------------------------------------------- /test/transform/ts/rootLevel.ts: -------------------------------------------------------------------------------- 1 | // TEST Process: 2 | // delete a generated lines 3 | //// Now compile and see if they reappear 4 | 5 | // valid argument folder with index 6 | ///ts:import=foo 7 | import foo = require('./foo/index'); ///ts:import:generated 8 | 9 | // valid argument folder without index 10 | ///ts:import=bar 11 | import c1 = require('./bar/c/c1'); ///ts:import:generated 12 | import c2 = require('./bar/c/c2'); ///ts:import:generated 13 | 14 | // valid argument file 15 | ///ts:import=A1 16 | import A1 = require('./foo/a/A1'); ///ts:import:generated 17 | 18 | // valid argument file renamed 19 | ///ts:import=A1,a1 20 | import a1 = require('./foo/a/A1'); ///ts:import:generated 21 | 22 | ///ts:import=nonexistent 23 | /// No file or directory matched name "nonexistent" ///ts:import:generated 24 | 25 | ///ts:someunknowntransform 26 | /// Unknown transform ///ts:unknown:generated 27 | -------------------------------------------------------------------------------- /docs/fast.md: -------------------------------------------------------------------------------- 1 | # Fast compile configuration 2 | Note : You must use *external modules* to be effective with `grunt-ts` fast compile. 3 | 4 | Configuration is done via the `fast` *task* option. The following values are supported: 5 | 6 | ## watch 7 | `watch`(default) which will clear the cache of the current target the first time it is called after `grunt-ts` has loaded (basically assumming that the js might have been out of date and just regenerating it *once*). 8 | ## always 9 | `always` will *never* clear the cache (the `.tscache` folder) and it is up to the user to clear it (delete the `.tscache` folder) if they purge the js. This is useful when you are using something like `webstorm` which always restarts `grunt-ts` and therefore we cannot take responsibility of clearing the cache for your. Use the option for `grunt-contrib-watch` as well. 10 | ## never 11 | `never` Disables fast compile. 12 | -------------------------------------------------------------------------------- /test/expected/transform/ts/rootLevel.ts: -------------------------------------------------------------------------------- 1 | // TEST Process: 2 | // delete a generated lines 3 | //// Now compile and see if they reappear 4 | 5 | // valid argument folder with index 6 | ///ts:import=foo 7 | import foo = require('./foo/index'); ///ts:import:generated 8 | 9 | // valid argument folder without index 10 | ///ts:import=bar 11 | import c1 = require('./bar/c/c1'); ///ts:import:generated 12 | import c2 = require('./bar/c/c2'); ///ts:import:generated 13 | 14 | // valid argument file 15 | ///ts:import=A1 16 | import A1 = require('./foo/a/A1'); ///ts:import:generated 17 | 18 | // valid argument file renamed 19 | ///ts:import=A1,a1 20 | import a1 = require('./foo/a/A1'); ///ts:import:generated 21 | 22 | ///ts:import=nonexistent 23 | /// No file or directory matched name "nonexistent" ///ts:import:generated 24 | 25 | ///ts:someunknowntransform 26 | /// Unknown transform ///ts:unknown:generated 27 | -------------------------------------------------------------------------------- /test/expected/varreplacedtest/grunt-ts-test.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"grunt-ts-test.js","sourceRoot":"","sources":["../simple/ts/zoo.ts"],"names":[],"mappings":";;;;;;;;;;AAAA;IACI,gBAAmB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAI,CAAC;IACpC,qBAAI,GAAJ,UAAK,MAAc;QACf,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAAC,CAAC;IACjD,CAAC;IACL,aAAC;AAAD,CAAC,AALD,IAKC;AAED;IAAoB,yBAAM;IACtB,eAAY,IAAY;eAAI,kBAAM,IAAI,CAAC;IAAE,CAAC;IAC1C,oBAAI,GAAJ;QACI,KAAK,CAAC,eAAe,CAAC,CAAC;QACvB,iBAAM,IAAI,YAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACL,YAAC;AAAD,CAAC,AAND,CAAoB,MAAM,GAMzB;AAED;IAAoB,yBAAM;IACtB,eAAY,IAAY;eAAI,kBAAM,IAAI,CAAC;IAAE,CAAC;IAC1C,oBAAI,GAAJ;QACI,KAAK,CAAC,cAAc,CAAC,CAAC;QACtB,iBAAM,IAAI,YAAC,EAAE,CAAC,CAAC;IACnB,CAAC;IACL,YAAC;AAAD,CAAC,AAND,CAAoB,MAAM,GAMzB;AAED,IAAI,GAAG,GAAG,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;AACxC,IAAI,GAAG,GAAW,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;AAElD,GAAG,CAAC,IAAI,EAAE,CAAC;AACX,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC"} -------------------------------------------------------------------------------- /test/tsconfig_artifact/newlineConfigs/lf_newline_tsconfig.expected.json.ts: -------------------------------------------------------------------------------- 1 | export const lf_newline_tsconfig_expected_json = 2 | '{\n' + 3 | ' "version": "1.5.3",\n' + 4 | ' "compilerOptions": {\n' + 5 | ' "target": "es6",\n' + 6 | ' "module": "amd",\n' + 7 | ' "declaration": true,\n' + 8 | ' "noImplicitAny": true,\n' + 9 | ' "removeComments": false,\n' + 10 | ' "noLib": true,\n' + 11 | ' "preserveConstEnums": false,\n' + 12 | ' "suppressImplicitAnyIndexErrors": true,\n' + 13 | ' "sourceMap": false,\n' + 14 | ' "inlineSourceMap": true,\n' + 15 | ' "inlineSources": true,\n' + 16 | ' "emitDecoratorMetadata": true,\n' + 17 | ' "experimentalDecorators": true\n' + 18 | ' },\n' + 19 | ' "filesGlob": [\n' + 20 | ' "./**/*.ts"\n' + 21 | ' ],\n' + 22 | ' "files": [\n' + 23 | ' "files/validtsconfig.ts",\n' + 24 | ' "otherFiles/other.ts",\n' + 25 | ' "otherFiles/that.ts",\n' + 26 | ' "otherFiles/this.ts"\n' + 27 | ' ]\n' + 28 | '}\n' 29 | -------------------------------------------------------------------------------- /test/tsconfig_artifact/newlineConfigs/lf_newline_tsconfig.json.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.lf_newline_tsconfig_json = '{\n' + 4 | ' "version": "1.5.3",\n' + 5 | ' "compilerOptions": {\n' + 6 | ' "target": "es6",\n' + 7 | ' "module": "amd",\n' + 8 | ' "declaration": true,\n' + 9 | ' "noImplicitAny": true,\n' + 10 | ' "removeComments": false,\n' + 11 | ' "noLib": true,\n' + 12 | ' "preserveConstEnums": false,\n' + 13 | ' "suppressImplicitAnyIndexErrors": true,\n' + 14 | ' "sourceMap": false,\n' + 15 | ' "inlineSourceMap": true,\n' + 16 | ' "inlineSources": true,\n' + 17 | ' "emitDecoratorMetadata": true,\n' + 18 | ' "experimentalDecorators": true\n' + 19 | ' },\n' + 20 | ' "filesGlob": [\n' + 21 | ' "./**/*.ts"\n' + 22 | ' ]\n' + 23 | '}\n'; 24 | //# sourceMappingURL=lf_newline_tsconfig.json.js.map -------------------------------------------------------------------------------- /test/expected/transform/js/foo/a/A2.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __extends = (this && this.__extends) || (function () { 3 | var extendStatics = Object.setPrototypeOf || 4 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 5 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 6 | return function (d, b) { 7 | extendStatics(d, b); 8 | function __() { this.constructor = d; } 9 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 10 | }; 11 | })(); 12 | var A1 = require("./A1"); 13 | var A2 = /** @class */ (function (_super) { 14 | __extends(A2, _super); 15 | function A2() { 16 | return _super !== null && _super.apply(this, arguments) || this; 17 | } 18 | A2.prototype.a2 = function () { return this.a1() + "a2"; }; 19 | return A2; 20 | }(A1)); 21 | module.exports = A2; 22 | //# sourceMappingURL=A2.js.map -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "bitwise": true, 3 | "camelcase": false, 4 | "curly": true, 5 | "eqeqeq": true, 6 | "es3": false, 7 | "forin": true, 8 | "freeze": true, 9 | "immed": true, 10 | "indent": 4, 11 | "latedef": true, 12 | "newcap": true, 13 | "noarg": true, 14 | "noempty": true, 15 | "nonew": true, 16 | "plusplus": false, 17 | "quotmark": true, 18 | "undef": true, 19 | "unused": true, 20 | "strict": false, 21 | "trailing": true, 22 | 23 | "maxlen": 120, 24 | 25 | "smarttabs": true, 26 | 27 | "browser": false, 28 | "devel": false, 29 | "node": true, 30 | "worker": false, 31 | 32 | "globals": { 33 | "describe": true, 34 | "it": true, 35 | "beforeEach": true, 36 | "afterEach": true, 37 | "before": true, 38 | "after": true, 39 | "define": true, 40 | "chai": true, 41 | "assert": true 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /test/expected/transform/js/foo/b/b2.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __extends = (this && this.__extends) || (function () { 3 | var extendStatics = Object.setPrototypeOf || 4 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 5 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 6 | return function (d, b) { 7 | extendStatics(d, b); 8 | function __() { this.constructor = d; } 9 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 10 | }; 11 | })(); 12 | exports.__esModule = true; 13 | var B1 = require("./b1"); 14 | var B2 = /** @class */ (function (_super) { 15 | __extends(B2, _super); 16 | function B2() { 17 | return _super !== null && _super.apply(this, arguments) || this; 18 | } 19 | B2.prototype.b2 = function () { return this.b1() + "b2"; }; 20 | return B2; 21 | }(B1.B1)); 22 | exports.B2 = B2; 23 | //# sourceMappingURL=b2.js.map -------------------------------------------------------------------------------- /test/expected/htmlTemplate/out.js: -------------------------------------------------------------------------------- 1 | /* tslint:disable:max-line-length */ 2 | var advanced; 3 | (function (advanced) { 4 | var $$template; 5 | (function ($$template) { 6 | var name; 7 | (function (name) { 8 | var tpl_html_module; 9 | (function (tpl_html_module) { 10 | tpl_html_module.advanced_$$template_name_tpl_html_variable = '
Some content
some other content '; 11 | })(tpl_html_module = name.tpl_html_module || (name.tpl_html_module = {})); 12 | })(name = $$template.name || ($$template.name = {})); 13 | })($$template = advanced.$$template || (advanced.$$template = {})); 14 | })(advanced || (advanced = {})); 15 | /// 16 | var boo = advanced.$$template.name.tpl_html_module.advanced_$$template_name_tpl_html_variable; 17 | //grunt-start 18 | /// 19 | /// 20 | //grunt-end 21 | //# sourceMappingURL=out.js.map -------------------------------------------------------------------------------- /grunt-ts.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30723.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "grunt-ts", "grunt-ts.csproj", "{FF8D9288-C427-4139-B162-E74D73D8F8D5}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {FF8D9288-C427-4139-B162-E74D73D8F8D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {FF8D9288-C427-4139-B162-E74D73D8F8D5}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {FF8D9288-C427-4139-B162-E74D73D8F8D5}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {FF8D9288-C427-4139-B162-E74D73D8F8D5}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /test/tsconfig_artifact/newlineConfigs/mixed_newline_tsconfig.expected.json.ts: -------------------------------------------------------------------------------- 1 | export const mixed_newline_tsconfig_expected_json = 2 | '{\n' + 3 | ' "version": "1.5.3",\n' + 4 | ' "compilerOptions": {\n' + 5 | ' "target": "es6",\n' + 6 | ' "module": "amd",\n' + 7 | ' "declaration": true,\n' + 8 | ' "noImplicitAny": true,\n' + 9 | ' "removeComments": false,\n' + 10 | ' "noLib": true,\n' + 11 | ' "preserveConstEnums": false,\n' + 12 | ' "suppressImplicitAnyIndexErrors": true,\n' + 13 | ' "sourceMap": false,\n' + 14 | ' "inlineSourceMap": true,\n' + 15 | ' "inlineSources": true,\n' + 16 | ' "emitDecoratorMetadata": true,\n' + 17 | ' "experimentalDecorators": true\n' + 18 | ' },\n' + 19 | ' "filesGlob": [\n' + 20 | ' "./**/*.ts"\n' + 21 | ' ],\n' + 22 | ' "files": [\n' + 23 | ' "files/validtsconfig.ts",\n' + 24 | ' "otherFiles/other.ts",\n' + 25 | ' "otherFiles/that.ts",\n' + 26 | ' "otherFiles/this.ts"\n' + 27 | ' ]\n' + 28 | '}\n' 29 | -------------------------------------------------------------------------------- /test/tsconfig_artifact/newlineConfigs/mixed_newline_tsconfig.json.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.mixed_newline_tsconfig_json = '{\r\n' + 4 | ' "version": "1.5.3",\r\n' + 5 | ' "compilerOptions": {\r\n' + 6 | ' "target": "es6",\n' + 7 | ' "module": "amd",\n' + 8 | ' "declaration": true,\n' + 9 | ' "noImplicitAny": true,\r\n' + 10 | ' "removeComments": false,\n' + 11 | ' "noLib": true,\n' + 12 | ' "preserveConstEnums": false,\n' + 13 | ' "suppressImplicitAnyIndexErrors": true,\n' + 14 | ' "sourceMap": false,\n' + 15 | ' "inlineSourceMap": true,\n' + 16 | ' "inlineSources": true,\n' + 17 | ' "emitDecoratorMetadata": true,\n' + 18 | ' "experimentalDecorators": true\n' + 19 | ' },\n' + 20 | ' "filesGlob": [\r\n' + 21 | ' "./**/*.ts"\r\n' + 22 | ' ]\n' + 23 | '}\r\n'; 24 | //# sourceMappingURL=mixed_newline_tsconfig.json.js.map -------------------------------------------------------------------------------- /test/tsconfig_artifact/newlineConfigs/crlf_newline_tsconfig.json.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.crlf_newline_tsconfig_json = '{\r\n' + 4 | ' "version": "1.5.3",\r\n' + 5 | ' "compilerOptions": {\r\n' + 6 | ' "target": "es6",\r\n' + 7 | ' "module": "amd",\r\n' + 8 | ' "declaration": true,\r\n' + 9 | ' "noImplicitAny": true,\r\n' + 10 | ' "removeComments": false,\r\n' + 11 | ' "noLib": true,\r\n' + 12 | ' "preserveConstEnums": false,\r\n' + 13 | ' "suppressImplicitAnyIndexErrors": true,\r\n' + 14 | ' "sourceMap": false,\r\n' + 15 | ' "inlineSourceMap": true,\r\n' + 16 | ' "inlineSources": true,\r\n' + 17 | ' "emitDecoratorMetadata": true,\r\n' + 18 | ' "experimentalDecorators": true\r\n' + 19 | ' },\r\n' + 20 | ' "filesGlob": [\r\n' + 21 | ' "./**/*.ts"\r\n' + 22 | ' ]\r\n' + 23 | '}\r\n'; 24 | //# sourceMappingURL=crlf_newline_tsconfig.json.js.map -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any person 2 | obtaining a copy of this software and associated documentation 3 | files (the "Software"), to deal in the Software without 4 | restriction, including without limitation the rights to use, 5 | copy, modify, merge, publish, distribute, sublicense, and/or sell 6 | copies of the Software, and to permit persons to whom the 7 | Software is furnished to do so, subject to the following 8 | conditions: 9 | 10 | The above copyright notice and this permission notice shall be 11 | included in all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 14 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 15 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 16 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 17 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /test/tsconfig_artifact/newlineConfigs/crlf_newline_tsconfig.expected.json.ts: -------------------------------------------------------------------------------- 1 | export const crlf_newline_tsconfig_expected_json = 2 | '{\r\n' + 3 | ' "version": "1.5.3",\r\n' + 4 | ' "compilerOptions": {\r\n' + 5 | ' "target": "es6",\r\n' + 6 | ' "module": "amd",\r\n' + 7 | ' "declaration": true,\r\n' + 8 | ' "noImplicitAny": true,\r\n' + 9 | ' "removeComments": false,\r\n' + 10 | ' "noLib": true,\r\n' + 11 | ' "preserveConstEnums": false,\r\n' + 12 | ' "suppressImplicitAnyIndexErrors": true,\r\n' + 13 | ' "sourceMap": false,\r\n' + 14 | ' "inlineSourceMap": true,\r\n' + 15 | ' "inlineSources": true,\r\n' + 16 | ' "emitDecoratorMetadata": true,\r\n' + 17 | ' "experimentalDecorators": true\r\n' + 18 | ' },\r\n' + 19 | ' "filesGlob": [\r\n' + 20 | ' "./**/*.ts"\r\n' + 21 | ' ],\r\n' + 22 | ' "files": [\r\n' + 23 | ' "files/validtsconfig.ts",\r\n' + 24 | ' "otherFiles/other.ts",\r\n' + 25 | ' "otherFiles/that.ts",\r\n' + 26 | ' "otherFiles/this.ts"\r\n' + 27 | ' ]\r\n' + 28 | '}\r\n' 29 | -------------------------------------------------------------------------------- /test/tsconfig_artifact/newlineConfigs/lf_newline_tsconfig.expected.json.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.lf_newline_tsconfig_expected_json = '{\n' + 4 | ' "version": "1.5.3",\n' + 5 | ' "compilerOptions": {\n' + 6 | ' "target": "es6",\n' + 7 | ' "module": "amd",\n' + 8 | ' "declaration": true,\n' + 9 | ' "noImplicitAny": true,\n' + 10 | ' "removeComments": false,\n' + 11 | ' "noLib": true,\n' + 12 | ' "preserveConstEnums": false,\n' + 13 | ' "suppressImplicitAnyIndexErrors": true,\n' + 14 | ' "sourceMap": false,\n' + 15 | ' "inlineSourceMap": true,\n' + 16 | ' "inlineSources": true,\n' + 17 | ' "emitDecoratorMetadata": true,\n' + 18 | ' "experimentalDecorators": true\n' + 19 | ' },\n' + 20 | ' "filesGlob": [\n' + 21 | ' "./**/*.ts"\n' + 22 | ' ],\n' + 23 | ' "files": [\n' + 24 | ' "files/validtsconfig.ts",\n' + 25 | ' "otherFiles/other.ts",\n' + 26 | ' "otherFiles/that.ts",\n' + 27 | ' "otherFiles/this.ts"\n' + 28 | ' ]\n' + 29 | '}\n'; 30 | //# sourceMappingURL=lf_newline_tsconfig.expected.json.js.map -------------------------------------------------------------------------------- /test/tsconfig_artifact/newlineConfigs/mixed_newline_tsconfig.expected.json.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.mixed_newline_tsconfig_expected_json = '{\n' + 4 | ' "version": "1.5.3",\n' + 5 | ' "compilerOptions": {\n' + 6 | ' "target": "es6",\n' + 7 | ' "module": "amd",\n' + 8 | ' "declaration": true,\n' + 9 | ' "noImplicitAny": true,\n' + 10 | ' "removeComments": false,\n' + 11 | ' "noLib": true,\n' + 12 | ' "preserveConstEnums": false,\n' + 13 | ' "suppressImplicitAnyIndexErrors": true,\n' + 14 | ' "sourceMap": false,\n' + 15 | ' "inlineSourceMap": true,\n' + 16 | ' "inlineSources": true,\n' + 17 | ' "emitDecoratorMetadata": true,\n' + 18 | ' "experimentalDecorators": true\n' + 19 | ' },\n' + 20 | ' "filesGlob": [\n' + 21 | ' "./**/*.ts"\n' + 22 | ' ],\n' + 23 | ' "files": [\n' + 24 | ' "files/validtsconfig.ts",\n' + 25 | ' "otherFiles/other.ts",\n' + 26 | ' "otherFiles/that.ts",\n' + 27 | ' "otherFiles/this.ts"\n' + 28 | ' ]\n' + 29 | '}\n'; 30 | //# sourceMappingURL=mixed_newline_tsconfig.expected.json.js.map -------------------------------------------------------------------------------- /test/expected/abtest/out.js: -------------------------------------------------------------------------------- 1 | var __extends = (this && this.__extends) || (function () { 2 | var extendStatics = Object.setPrototypeOf || 3 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 4 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 5 | return function (d, b) { 6 | extendStatics(d, b); 7 | function __() { this.constructor = d; } 8 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 9 | }; 10 | })(); 11 | var C = /** @class */ (function () { 12 | function C() { 13 | } 14 | return C; 15 | }()); 16 | /// 17 | var B = /** @class */ (function (_super) { 18 | __extends(B, _super); 19 | function B() { 20 | return _super !== null && _super.apply(this, arguments) || this; 21 | } 22 | return B; 23 | }(C)); 24 | /// 25 | var A = /** @class */ (function (_super) { 26 | __extends(A, _super); 27 | function A() { 28 | return _super !== null && _super.apply(this, arguments) || this; 29 | } 30 | return A; 31 | }(B)); 32 | /// 33 | //grunt-start 34 | /// 35 | //grunt-end 36 | /// 37 | //# sourceMappingURL=out.js.map -------------------------------------------------------------------------------- /test/expected/files_ObjectFormat/a.js: -------------------------------------------------------------------------------- 1 | var __extends = (this && this.__extends) || (function () { 2 | var extendStatics = Object.setPrototypeOf || 3 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 4 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 5 | return function (d, b) { 6 | extendStatics(d, b); 7 | function __() { this.constructor = d; } 8 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 9 | }; 10 | })(); 11 | var C = /** @class */ (function () { 12 | function C() { 13 | } 14 | return C; 15 | }()); 16 | /// 17 | var B = /** @class */ (function (_super) { 18 | __extends(B, _super); 19 | function B() { 20 | return _super !== null && _super.apply(this, arguments) || this; 21 | } 22 | return B; 23 | }(C)); 24 | /// 25 | //grunt-start 26 | /// 27 | //grunt-end 28 | /// 29 | /// 30 | var A = /** @class */ (function (_super) { 31 | __extends(A, _super); 32 | function A() { 33 | return _super !== null && _super.apply(this, arguments) || this; 34 | } 35 | return A; 36 | }(B)); 37 | //# sourceMappingURL=a.js.map -------------------------------------------------------------------------------- /test/tsconfig_artifact/newlineConfigs/crlf_newline_tsconfig.expected.json.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.crlf_newline_tsconfig_expected_json = '{\r\n' + 4 | ' "version": "1.5.3",\r\n' + 5 | ' "compilerOptions": {\r\n' + 6 | ' "target": "es6",\r\n' + 7 | ' "module": "amd",\r\n' + 8 | ' "declaration": true,\r\n' + 9 | ' "noImplicitAny": true,\r\n' + 10 | ' "removeComments": false,\r\n' + 11 | ' "noLib": true,\r\n' + 12 | ' "preserveConstEnums": false,\r\n' + 13 | ' "suppressImplicitAnyIndexErrors": true,\r\n' + 14 | ' "sourceMap": false,\r\n' + 15 | ' "inlineSourceMap": true,\r\n' + 16 | ' "inlineSources": true,\r\n' + 17 | ' "emitDecoratorMetadata": true,\r\n' + 18 | ' "experimentalDecorators": true\r\n' + 19 | ' },\r\n' + 20 | ' "filesGlob": [\r\n' + 21 | ' "./**/*.ts"\r\n' + 22 | ' ],\r\n' + 23 | ' "files": [\r\n' + 24 | ' "files/validtsconfig.ts",\r\n' + 25 | ' "otherFiles/other.ts",\r\n' + 26 | ' "otherFiles/that.ts",\r\n' + 27 | ' "otherFiles/this.ts"\r\n' + 28 | ' ]\r\n' + 29 | '}\r\n'; 30 | //# sourceMappingURL=crlf_newline_tsconfig.expected.json.js.map -------------------------------------------------------------------------------- /customcompiler/lib.scripthost.d.ts: -------------------------------------------------------------------------------- 1 | /*! ***************************************************************************** 2 | Copyright (c) Microsoft Corporation. All rights reserved. 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | this file except in compliance with the License. You may obtain a copy of the 5 | License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 8 | KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 9 | WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 10 | MERCHANTABLITY OR NON-INFRINGEMENT. 11 | 12 | See the Apache Version 2.0 License for specific language governing permissions 13 | and limitations under the License. 14 | ***************************************************************************** */ 15 | 16 | /// 17 | 18 | 19 | ///////////////////////////// 20 | /// Windows Script Host APIS 21 | ///////////////////////////// 22 | 23 | declare var ActiveXObject: { new (s: string): any; }; 24 | 25 | interface ITextWriter { 26 | Write(s: string): void; 27 | WriteLine(s: string): void; 28 | Close(): void; 29 | } 30 | 31 | declare var WScript: { 32 | Echo(s: any): void; 33 | StdErr: ITextWriter; 34 | StdOut: ITextWriter; 35 | Arguments: { length: number; Item(n: number): string; }; 36 | ScriptFullName: string; 37 | Quit(exitCode?: number): number; 38 | } 39 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible Node.js debug attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "name": "Nodeunit Debug", 11 | "program": "${workspaceRoot}/node_modules/nodeunit/bin/nodeunit", 12 | "cwd": "${workspaceRoot}", 13 | "outFiles": [], 14 | "sourceMaps": true, 15 | "args": [ 16 | "test/optionsResolverTests.js", 17 | "-t", 18 | "if no files, but exclude, *.ts and *.tsx will be included except for the excluded files and folders", 19 | ] 20 | },{ 21 | "type": "node", 22 | "request": "launch", 23 | "name": "Grunt Debug (Windows)", 24 | "program": "${env.APPDATA}/npm/node_modules/grunt-cli/bin/grunt", 25 | "cwd": "${workspaceRoot}", 26 | "outFiles": [], 27 | "sourceMaps": true, 28 | "args": [ 29 | "ts:issue_392", 30 | "--verbose" 31 | ] 32 | }, 33 | { 34 | "type": "node", 35 | "request": "attach", 36 | "name": "Attach to Process", 37 | "port": 5858, 38 | "outFiles": [], 39 | "sourceMaps": true 40 | } 41 | ] 42 | } -------------------------------------------------------------------------------- /test/expected/out with spaces/zoo.js: -------------------------------------------------------------------------------- 1 | var __extends = (this && this.__extends) || (function () { 2 | var extendStatics = Object.setPrototypeOf || 3 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 4 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 5 | return function (d, b) { 6 | extendStatics(d, b); 7 | function __() { this.constructor = d; } 8 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 9 | }; 10 | })(); 11 | var Animal = (function () { 12 | function Animal(name) { 13 | this.name = name; 14 | } 15 | Animal.prototype.move = function (meters) { 16 | alert(this.name + " moved " + meters + "m."); 17 | }; 18 | return Animal; 19 | }()); 20 | var Snake = (function (_super) { 21 | __extends(Snake, _super); 22 | function Snake(name) { 23 | return _super.call(this, name) || this; 24 | } 25 | Snake.prototype.move = function () { 26 | alert("Slithering..."); 27 | _super.prototype.move.call(this, 5); 28 | }; 29 | return Snake; 30 | }(Animal)); 31 | var Horse = (function (_super) { 32 | __extends(Horse, _super); 33 | function Horse(name) { 34 | return _super.call(this, name) || this; 35 | } 36 | Horse.prototype.move = function () { 37 | alert("Galloping..."); 38 | _super.prototype.move.call(this, 45); 39 | }; 40 | return Horse; 41 | }(Animal)); 42 | var sam = new Snake("Sammy the Python"); 43 | var tom = new Horse("Tommy the Palomino"); 44 | sam.move(); 45 | tom.move(34); 46 | -------------------------------------------------------------------------------- /test/expected/simple_with_rootDir/js/ts/zoo.js: -------------------------------------------------------------------------------- 1 | var __extends = (this && this.__extends) || (function () { 2 | var extendStatics = Object.setPrototypeOf || 3 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 4 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 5 | return function (d, b) { 6 | extendStatics(d, b); 7 | function __() { this.constructor = d; } 8 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 9 | }; 10 | })(); 11 | var Animal = (function () { 12 | function Animal(name) { 13 | this.name = name; 14 | } 15 | Animal.prototype.move = function (meters) { 16 | alert(this.name + " moved " + meters + "m."); 17 | }; 18 | return Animal; 19 | }()); 20 | var Snake = (function (_super) { 21 | __extends(Snake, _super); 22 | function Snake(name) { 23 | return _super.call(this, name) || this; 24 | } 25 | Snake.prototype.move = function () { 26 | alert("Slithering..."); 27 | _super.prototype.move.call(this, 5); 28 | }; 29 | return Snake; 30 | }(Animal)); 31 | var Horse = (function (_super) { 32 | __extends(Horse, _super); 33 | function Horse(name) { 34 | return _super.call(this, name) || this; 35 | } 36 | Horse.prototype.move = function () { 37 | alert("Galloping..."); 38 | _super.prototype.move.call(this, 45); 39 | }; 40 | return Horse; 41 | }(Animal)); 42 | var sam = new Snake("Sammy the Python"); 43 | var tom = new Horse("Tommy the Palomino"); 44 | sam.move(); 45 | tom.move(34); 46 | -------------------------------------------------------------------------------- /test/expected/simple/js/zoo.js: -------------------------------------------------------------------------------- 1 | var __extends = (this && this.__extends) || (function () { 2 | var extendStatics = Object.setPrototypeOf || 3 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 4 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 5 | return function (d, b) { 6 | extendStatics(d, b); 7 | function __() { this.constructor = d; } 8 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 9 | }; 10 | })(); 11 | var Animal = (function () { 12 | function Animal(name) { 13 | this.name = name; 14 | } 15 | Animal.prototype.move = function (meters) { 16 | alert(this.name + " moved " + meters + "m."); 17 | }; 18 | return Animal; 19 | }()); 20 | var Snake = (function (_super) { 21 | __extends(Snake, _super); 22 | function Snake(name) { 23 | return _super.call(this, name) || this; 24 | } 25 | Snake.prototype.move = function () { 26 | alert("Slithering..."); 27 | _super.prototype.move.call(this, 5); 28 | }; 29 | return Snake; 30 | }(Animal)); 31 | var Horse = (function (_super) { 32 | __extends(Horse, _super); 33 | function Horse(name) { 34 | return _super.call(this, name) || this; 35 | } 36 | Horse.prototype.move = function () { 37 | alert("Galloping..."); 38 | _super.prototype.move.call(this, 45); 39 | }; 40 | return Horse; 41 | }(Animal)); 42 | var sam = new Snake("Sammy the Python"); 43 | var tom = new Horse("Tommy the Palomino"); 44 | sam.move(); 45 | tom.move(34); 46 | //# sourceMappingURL=zoo.js.map -------------------------------------------------------------------------------- /test/expected/nestedSources/zoo.js: -------------------------------------------------------------------------------- 1 | var __extends = (this && this.__extends) || (function () { 2 | var extendStatics = Object.setPrototypeOf || 3 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 4 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 5 | return function (d, b) { 6 | extendStatics(d, b); 7 | function __() { this.constructor = d; } 8 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 9 | }; 10 | })(); 11 | var Animal = (function () { 12 | function Animal(name) { 13 | this.name = name; 14 | } 15 | Animal.prototype.move = function (meters) { 16 | alert(this.name + " moved " + meters + "m."); 17 | }; 18 | return Animal; 19 | }()); 20 | var Snake = (function (_super) { 21 | __extends(Snake, _super); 22 | function Snake(name) { 23 | return _super.call(this, name) || this; 24 | } 25 | Snake.prototype.move = function () { 26 | alert("Slithering..."); 27 | _super.prototype.move.call(this, 5); 28 | }; 29 | return Snake; 30 | }(Animal)); 31 | var Horse = (function (_super) { 32 | __extends(Horse, _super); 33 | function Horse(name) { 34 | return _super.call(this, name) || this; 35 | } 36 | Horse.prototype.move = function () { 37 | alert("Galloping..."); 38 | _super.prototype.move.call(this, 45); 39 | }; 40 | return Horse; 41 | }(Animal)); 42 | var sam = new Snake("Sammy the Python"); 43 | var tom = new Horse("Tommy the Palomino"); 44 | sam.move(); 45 | tom.move(34); 46 | //# sourceMappingURL=zoo.js.map -------------------------------------------------------------------------------- /test/expected/varreplacedtest/grunt-ts-test.js: -------------------------------------------------------------------------------- 1 | var __extends = (this && this.__extends) || (function () { 2 | var extendStatics = Object.setPrototypeOf || 3 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 4 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 5 | return function (d, b) { 6 | extendStatics(d, b); 7 | function __() { this.constructor = d; } 8 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 9 | }; 10 | })(); 11 | var Animal = (function () { 12 | function Animal(name) { 13 | this.name = name; 14 | } 15 | Animal.prototype.move = function (meters) { 16 | alert(this.name + " moved " + meters + "m."); 17 | }; 18 | return Animal; 19 | }()); 20 | var Snake = (function (_super) { 21 | __extends(Snake, _super); 22 | function Snake(name) { 23 | return _super.call(this, name) || this; 24 | } 25 | Snake.prototype.move = function () { 26 | alert("Slithering..."); 27 | _super.prototype.move.call(this, 5); 28 | }; 29 | return Snake; 30 | }(Animal)); 31 | var Horse = (function (_super) { 32 | __extends(Horse, _super); 33 | function Horse(name) { 34 | return _super.call(this, name) || this; 35 | } 36 | Horse.prototype.move = function () { 37 | alert("Galloping..."); 38 | _super.prototype.move.call(this, 45); 39 | }; 40 | return Horse; 41 | }(Animal)); 42 | var sam = new Snake("Sammy the Python"); 43 | var tom = new Horse("Tommy the Palomino"); 44 | sam.move(); 45 | tom.move(34); 46 | //# sourceMappingURL=grunt-ts-test.js.map -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.8.9", 3 | "compilerOptions": { 4 | "target": "es5", 5 | "module": "commonjs", 6 | "declaration": false, 7 | "noImplicitAny": false, 8 | "removeComments": false, 9 | "noLib": false, 10 | "preserveConstEnums": false, 11 | "suppressImplicitAnyIndexErrors": true, 12 | "sourceMap": true, 13 | "moduleResolution": "node" 14 | }, 15 | "filesGlob": [ 16 | "./defs/**/*.ts", 17 | "./tasks/**/*.ts", 18 | "./test/*.ts", 19 | "./test/tsconfig_artifact/newlineConfigs/*.ts" 20 | ], 21 | "files": [ 22 | "defs/es6-promise/es6-promise.d.ts", 23 | "defs/gruntjs/gruntjs.d.ts", 24 | "defs/lodash/lodash.d.ts", 25 | "defs/node/node.d.ts", 26 | "defs/nodeunit/nodeunit.d.ts", 27 | "defs/tsd.d.ts", 28 | "tasks/modules/amdLoader.ts", 29 | "tasks/modules/cacheUtils.ts", 30 | "tasks/modules/compile.ts", 31 | "tasks/modules/defaults.ts", 32 | "tasks/modules/html2ts.ts", 33 | "tasks/modules/interfaces.d.ts", 34 | "tasks/modules/optionsResolver.ts", 35 | "tasks/modules/reference.ts", 36 | "tasks/modules/templateCache.ts", 37 | "tasks/modules/transformers.ts", 38 | "tasks/modules/tsconfig.ts", 39 | "tasks/modules/utils.ts", 40 | "tasks/modules/visualStudioOptionsResolver.ts", 41 | "tasks/scratch.ts", 42 | "tasks/ts.ts", 43 | "test/commandLineAssertions.ts", 44 | "test/optionsResolverTests.ts", 45 | "test/references-transform-library.d.ts", 46 | "test/test.ts" 47 | ], 48 | "exclude": [], 49 | "atom": { 50 | "rewriteTsconfig": false 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /test/testHelpers.ts: -------------------------------------------------------------------------------- 1 | var grunt: IGrunt = require('grunt'); 2 | import utils = require('../tasks/modules/utils'); 3 | import _ = require('lodash'); 4 | 5 | export function testFile(test, path: string, whitespaceDifferencesOK = false) { 6 | var actualFileName = 'test/' + path, 7 | expectedFileName = 'test/expected/' + path; 8 | 9 | var actual = grunt.file.read(actualFileName); 10 | var expected = grunt.file.read(expectedFileName); 11 | 12 | if (whitespaceDifferencesOK) { 13 | actual = actual.replace(/\s/g,''); 14 | expected = expected.replace(/\s/g,''); 15 | } 16 | 17 | test.equal(expected, actual, `Actual did not match expected. Run this to compare:` + 18 | `${grunt.util.linefeed}kdiff3 "${actualFileName}" "${expectedFileName}"`); 19 | } 20 | 21 | export function assertFileDoesNotExist(test, path: string) { 22 | var exists = grunt.file.exists(path); 23 | test.equal(false, exists, 'Expected this file to not exist: ' + path); 24 | } 25 | 26 | export function testExpectedFile(test, path: string, whitespaceDifferencesOK = false) { 27 | let actualFileName = path.replace('\\expected', '').replace('/expected', '') 28 | .replace('.expected.', '.'); 29 | let expectedFileName = path; 30 | 31 | var actual = grunt.file.read(actualFileName); 32 | var expected = grunt.file.read(expectedFileName); 33 | 34 | if (whitespaceDifferencesOK) { 35 | actual = actual.replace(/\s/g,''); 36 | expected = expected.replace(/\s/g,''); 37 | } 38 | 39 | test.equal(expected, actual, `Actual did not match expected. Run this to compare:` + 40 | `${grunt.util.linefeed}kdiff3 "${actualFileName}" "${expectedFileName}"`); 41 | } 42 | 43 | 44 | export function testDirectory(test, folder, whitespaceDifferencesOK = false) { 45 | var files = utils.getFiles(('test/expected/' + folder)); 46 | _.forEach(files, (expected: string) => { 47 | testExpectedFile(test, expected, whitespaceDifferencesOK); 48 | }); 49 | } 50 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "ban": [], 4 | "class-name": true, 5 | "comment-format": [true, 6 | "check-space" 7 | ], 8 | "curly": true, 9 | "eofline": true, 10 | "forin": true, 11 | "indent": [true, 4], 12 | "interface-name": false, 13 | "jsdoc-format": false, 14 | "label-position": true, 15 | "max-line-length": [true, 150], 16 | "no-arg": true, 17 | "no-bitwise": true, 18 | "no-console": [true, 19 | "debug", 20 | "info", 21 | "time", 22 | "timeEnd", 23 | "trace" 24 | ], 25 | "no-construct": true, 26 | "no-debugger": true, 27 | "no-duplicate-variable": true, 28 | "no-empty": false, 29 | "no-eval": true, 30 | "no-string-literal": false, 31 | "no-trailing-whitespace": true, 32 | "no-use-before-declare": true, 33 | "one-line": [true, 34 | "_check-catch", 35 | "_check-else", 36 | "check-open-brace", 37 | "check-whitespace" 38 | ], 39 | "quotemark": [true, 40 | "single" 41 | ], 42 | "radix": true, 43 | "semicolon": true, 44 | "triple-equals": [true, 45 | "allow-null-check" 46 | ], 47 | "typedef": [true, 48 | "indexSignature", 49 | "propertySignature" 50 | ], 51 | "typedef-whitespace": [true, 52 | { 53 | "callSignature": "nospace", 54 | "catchClause": "nospace", 55 | "indexSignature": "nospace", 56 | "parameter": "nospace", 57 | "propertySignature": "nospace", 58 | "variableDeclarator": "nospace" 59 | } 60 | ], 61 | "whitespace": [true, 62 | "check-type", 63 | "check-branch", 64 | "check-decl", 65 | "check-separator", 66 | "check-operator" 67 | ] 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "basarat", 3 | "name": "grunt-ts", 4 | "description": "Compile and manage your TypeScript project", 5 | "version": "6.0.0-beta.22", 6 | "homepage": "https://github.com/TypeStrong/grunt-ts", 7 | "repository": { 8 | "type": "git", 9 | "url": "git@github.com:TypeStrong/grunt-ts.git" 10 | }, 11 | "bugs": { 12 | "url": "https://github.com/TypeStrong/grunt-ts/issues" 13 | }, 14 | "license": "MIT", 15 | "main": "tasks/ts.js", 16 | "maintainers": [ 17 | { 18 | "name": "nycdotnet", 19 | "email": "steve.ognibene@outlook.com" 20 | }, 21 | { 22 | "name": "jeffmay", 23 | "email": "viralidealogue@gmail.com" 24 | }, 25 | { 26 | "name": "bartvds", 27 | "email": "bartvanderschoor@gmail.com" 28 | }, 29 | { 30 | "name": "basarat", 31 | "email": "basaratali@gmail.com" 32 | } 33 | ], 34 | "engines": { 35 | "node": ">= 0.8.0" 36 | }, 37 | "scripts": { 38 | "test": "grunt test --verbose --stack", 39 | "watch": "tsc -p . -w" 40 | }, 41 | "dependencies": { 42 | "chokidar": "^2.0.4", 43 | "csproj2ts": "^1.1.0", 44 | "detect-indent": "^4.0.0", 45 | "detect-newline": "^2.1.0", 46 | "es6-promise": "~0.1.1", 47 | "jsmin2": "^1.2.1", 48 | "lodash": "~4.17.10", 49 | "ncp": "0.5.1", 50 | "rimraf": "2.2.6", 51 | "semver": "^5.3.0", 52 | "strip-bom": "^2.0.0" 53 | }, 54 | "peerDependencies": { 55 | "grunt": "^1.0.0 || ^0.4.0", 56 | "typescript": ">=1" 57 | }, 58 | "devDependencies": { 59 | "grunt": "^1.0.3", 60 | "grunt-continue": "0.1.0", 61 | "grunt-contrib-clean": "~1.1.0", 62 | "grunt-contrib-jshint": "1.1.0", 63 | "grunt-contrib-nodeunit": "^2.0.0", 64 | "grunt-contrib-watch": "^1.1.0", 65 | "grunt-tslint": "4.0.1", 66 | "jshint-path-reporter": "~0.1.3", 67 | "tslint": "4.3.1", 68 | "typescript": "^2.9.2" 69 | }, 70 | "optionalDependencies": {}, 71 | "keywords": [ 72 | "grunt", 73 | "gruntplugin", 74 | "typescript", 75 | "compiler", 76 | "task", 77 | "visualstudio", 78 | "build" 79 | ] 80 | } -------------------------------------------------------------------------------- /test/tsconfig_artifact/full_valid_tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.5.3", 3 | "compilerOptions": { 4 | "target": "es5", 5 | "module": "commonjs", 6 | "declaration": false, 7 | "noImplicitAny": false, 8 | "removeComments": false, 9 | "noLib": false, 10 | "preserveConstEnums": false, 11 | "suppressImplicitAnyIndexErrors": true, 12 | "sourceMap": true, 13 | "outDir": "./files", 14 | "allowSyntheticDefaultImports": true, 15 | "charset": "utf8", 16 | "strictNullChecks": false, 17 | "listFiles": true, 18 | "typeRoots": ["./../node_modules/@types", "./../node_modules/types2_see_issue_391"], 19 | "types": ["see","issue","391"], 20 | "checkJs": true, 21 | "allowJs": true, 22 | "preserveSymlinks": true, 23 | "esModuleInterop": true 24 | }, 25 | "filesGlob": [ 26 | "./defs/**/*.ts", 27 | "./tasks/**/*.ts", 28 | "./test/*.ts" 29 | ], 30 | "files": [ 31 | "./defs/csproj2ts/csproj2ts.d.ts", 32 | "./defs/es6-promise/es6-promise.d.ts", 33 | "./defs/gruntjs/gruntjs.d.ts", 34 | "./defs/lodash/lodash.d.ts", 35 | "./defs/node/node.d.ts", 36 | "./defs/nodeunit/nodeunit.d.ts", 37 | "./defs/tsd.d.ts", 38 | "./tasks/deletedcode.ts", 39 | "./tasks/modules/amdLoader.ts", 40 | "./tasks/modules/cacheUtils.ts", 41 | "./tasks/modules/compile.ts", 42 | "./tasks/modules/defaults.ts", 43 | "./tasks/modules/html2ts.ts", 44 | "./tasks/modules/interfaces.d.ts", 45 | "./tasks/modules/optionsResolver.ts", 46 | "./tasks/modules/reference.ts", 47 | "./tasks/modules/templateCache.ts", 48 | "./tasks/modules/transformers.ts", 49 | "./tasks/modules/tsconfig.ts", 50 | "./tasks/modules/utils.ts", 51 | "./tasks/modules/visualStudioOptionsResolver.ts", 52 | "./tasks/scratch.ts", 53 | "./tasks/ts.ts", 54 | "./test/commandLineAssertions.ts", 55 | "./test/optionsResolverTests.ts", 56 | "./test/references-transform-library.d.ts", 57 | "./test/test.ts" 58 | ] 59 | } 60 | -------------------------------------------------------------------------------- /tasks/modules/templateCache.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var _ = require("lodash"); 4 | var fs = require("fs"); 5 | var path = require("path"); 6 | var utils = require("./utils"); 7 | function generateTemplateCache(src, dest, basePath, eol) { 8 | if (!src.length) { 9 | return; 10 | } 11 | var relativePaths = _.map(src, function (anHtmlFile) { return 'text!' + utils.makeRelativePath(basePath, anHtmlFile); }); 12 | var fileNames = _.map(src, function (anHtmlFile) { return path.basename(anHtmlFile); }); 13 | var fileVarialbeName = function (anHtmlFile) { return anHtmlFile.split('.').join('_').split('-').join('_'); }; 14 | var fileVariableNames = _.map(fileNames, fileVarialbeName); 15 | var templateCacheTemplate = _.template('// You must have requirejs + text plugin loaded for this to work.' 16 | + eol + 'define([<%=relativePathSection%>],function(<%=fileNameVariableSection%>){' 17 | + eol + 'angular.module("ng").run(["$templateCache",function($templateCache) {' 18 | + eol + '<%=templateCachePut%>' 19 | + eol + '}]);' 20 | + eol + '});'); 21 | var relativePathSection = '"' + relativePaths.join('",' + eol + '"') + '"'; 22 | var fileNameVariableSection = fileVariableNames.join(',' + eol); 23 | var templateCachePutTemplate = _.template('$templateCache.put("<%= fileName %>", <%=fileVariableName%>);'); 24 | var templateCachePut = _.map(fileNames, function (fileName) { return templateCachePutTemplate({ 25 | fileName: fileName, 26 | fileVariableName: fileVarialbeName(fileName) 27 | }); }).join(eol); 28 | var fileContent = templateCacheTemplate({ 29 | relativePathSection: relativePathSection, 30 | fileNameVariableSection: fileNameVariableSection, 31 | templateCachePut: templateCachePut 32 | }); 33 | if (fs.existsSync(dest)) { 34 | var originalContents = fs.readFileSync(dest).toString(); 35 | if (originalContents === fileContent) { 36 | return; 37 | } 38 | } 39 | fs.writeFileSync(dest, fileContent); 40 | } 41 | exports.generateTemplateCache = generateTemplateCache; 42 | //# sourceMappingURL=templateCache.js.map -------------------------------------------------------------------------------- /test/testHelpers.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var grunt = require('grunt'); 4 | var utils = require("../tasks/modules/utils"); 5 | var _ = require("lodash"); 6 | function testFile(test, path, whitespaceDifferencesOK) { 7 | if (whitespaceDifferencesOK === void 0) { whitespaceDifferencesOK = false; } 8 | var actualFileName = 'test/' + path, expectedFileName = 'test/expected/' + path; 9 | var actual = grunt.file.read(actualFileName); 10 | var expected = grunt.file.read(expectedFileName); 11 | if (whitespaceDifferencesOK) { 12 | actual = actual.replace(/\s/g, ''); 13 | expected = expected.replace(/\s/g, ''); 14 | } 15 | test.equal(expected, actual, "Actual did not match expected. Run this to compare:" + 16 | (grunt.util.linefeed + "kdiff3 \"" + actualFileName + "\" \"" + expectedFileName + "\"")); 17 | } 18 | exports.testFile = testFile; 19 | function assertFileDoesNotExist(test, path) { 20 | var exists = grunt.file.exists(path); 21 | test.equal(false, exists, 'Expected this file to not exist: ' + path); 22 | } 23 | exports.assertFileDoesNotExist = assertFileDoesNotExist; 24 | function testExpectedFile(test, path, whitespaceDifferencesOK) { 25 | if (whitespaceDifferencesOK === void 0) { whitespaceDifferencesOK = false; } 26 | var actualFileName = path.replace('\\expected', '').replace('/expected', '') 27 | .replace('.expected.', '.'); 28 | var expectedFileName = path; 29 | var actual = grunt.file.read(actualFileName); 30 | var expected = grunt.file.read(expectedFileName); 31 | if (whitespaceDifferencesOK) { 32 | actual = actual.replace(/\s/g, ''); 33 | expected = expected.replace(/\s/g, ''); 34 | } 35 | test.equal(expected, actual, "Actual did not match expected. Run this to compare:" + 36 | (grunt.util.linefeed + "kdiff3 \"" + actualFileName + "\" \"" + expectedFileName + "\"")); 37 | } 38 | exports.testExpectedFile = testExpectedFile; 39 | function testDirectory(test, folder, whitespaceDifferencesOK) { 40 | if (whitespaceDifferencesOK === void 0) { whitespaceDifferencesOK = false; } 41 | var files = utils.getFiles(('test/expected/' + folder)); 42 | _.forEach(files, function (expected) { 43 | testExpectedFile(test, expected, whitespaceDifferencesOK); 44 | }); 45 | } 46 | exports.testDirectory = testDirectory; 47 | //# sourceMappingURL=testHelpers.js.map -------------------------------------------------------------------------------- /test/expected/files_ObjectFormat/b.js: -------------------------------------------------------------------------------- 1 | var __extends = (this && this.__extends) || (function () { 2 | var extendStatics = Object.setPrototypeOf || 3 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 4 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 5 | return function (d, b) { 6 | extendStatics(d, b); 7 | function __() { this.constructor = d; } 8 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 9 | }; 10 | })(); 11 | var C = /** @class */ (function () { 12 | function C() { 13 | } 14 | return C; 15 | }()); 16 | /// 17 | var B = /** @class */ (function (_super) { 18 | __extends(B, _super); 19 | function B() { 20 | return _super !== null && _super.apply(this, arguments) || this; 21 | } 22 | return B; 23 | }(C)); 24 | /// 25 | //grunt-start 26 | /// 27 | //grunt-end 28 | /// 29 | /// 30 | var A = /** @class */ (function (_super) { 31 | __extends(A, _super); 32 | function A() { 33 | return _super !== null && _super.apply(this, arguments) || this; 34 | } 35 | return A; 36 | }(B)); 37 | var Animal = /** @class */ (function () { 38 | function Animal(name) { 39 | this.name = name; 40 | } 41 | Animal.prototype.move = function (meters) { 42 | alert(this.name + " moved " + meters + "m."); 43 | }; 44 | return Animal; 45 | }()); 46 | var Snake = /** @class */ (function (_super) { 47 | __extends(Snake, _super); 48 | function Snake(name) { 49 | return _super.call(this, name) || this; 50 | } 51 | Snake.prototype.move = function () { 52 | alert("Slithering..."); 53 | _super.prototype.move.call(this, 5); 54 | }; 55 | return Snake; 56 | }(Animal)); 57 | var Horse = /** @class */ (function (_super) { 58 | __extends(Horse, _super); 59 | function Horse(name) { 60 | return _super.call(this, name) || this; 61 | } 62 | Horse.prototype.move = function () { 63 | alert("Galloping..."); 64 | _super.prototype.move.call(this, 45); 65 | }; 66 | return Horse; 67 | }(Animal)); 68 | var sam = new Snake("Sammy the Python"); 69 | var tom = new Horse("Tommy the Palomino"); 70 | sam.move(); 71 | tom.move(34); 72 | //# sourceMappingURL=b.js.map -------------------------------------------------------------------------------- /defs/nodeunit/nodeunit.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for nodeunit 2 | // Project: https://github.com/caolan/nodeunit 3 | // Definitions by: Jeff Goddard 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | // Imported from: https://github.com/soywiz/typescript-node-definitions/nodeunit.d.ts 7 | 8 | declare module 'nodeunit' { 9 | export interface ITestCase { 10 | (testCase: {[property: string]: ITestBody | ITestGroup | void}) : void; 11 | } 12 | export var testCase : ITestCase; 13 | 14 | export interface Test { 15 | done: ICallbackFunction; 16 | expect(num: number): void; 17 | 18 | //assersions from node assert module 19 | fail(actual: any, expected: any, message: string, operator: string): void; 20 | assert(value: any, message: string): void; 21 | ok(value: any, message?: string): void; 22 | equal(actual: any, expected: any, message?: string): void; 23 | notEqual(actual: any, expected: any, message?: string): void; 24 | deepEqual(actual: any, expected: any, message?: string): void; 25 | notDeepEqual(actual: any, expected: any, message?: string): void; 26 | strictEqual(actual: any, expected: any, message?: string): void; 27 | notStrictEqual(actual: any, expected: any, message?: string): void; 28 | throws(block: any, error?: any, message?: string): void; 29 | doesNotThrow(block: any, error?: any, message?: string): void; 30 | ifError(value: any): void; 31 | 32 | //assertion wrappers 33 | equals(actual: any, expected: any, message?: string): void; 34 | same(actual: any, expected: any, message?: string): void; 35 | } 36 | 37 | // Test Group Usage: 38 | // var testGroup: nodeunit.ITestGroup = { 39 | // setUp: (callback) => { 40 | // callback(); 41 | // }, 42 | // tearDown: (callback) => { 43 | // callback(); 44 | // }, 45 | // test1: (test: nodeunit.Test) => { 46 | // test.done(); 47 | // } 48 | // } 49 | // exports.testgroup = testGroup; 50 | 51 | export interface ITestBody { 52 | (callback: Test): void; 53 | } 54 | 55 | export interface ITestGroup { 56 | /** The setUp function is run before each test */ 57 | setUp?: (callback: ICallbackFunction) => void; 58 | /** The tearDown function is run after each test calls test.done() */ 59 | tearDown?: (callback: ICallbackFunction) => void; 60 | [property: string] : ITestGroup | ITestBody | ((callback: ICallbackFunction) => void); 61 | } 62 | 63 | export interface ICallbackFunction { 64 | (err?: any): void; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /tasks/modules/templateCache.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import _ = require('lodash'); 4 | import fs = require('fs'); 5 | import path = require('path'); 6 | 7 | import utils = require('./utils'); 8 | 9 | ///////////////////////////////////////////////////////////////////// 10 | // AngularJS templateCache 11 | //////////////////////////////////////////////////////////////////// 12 | 13 | // templateCache processing function 14 | 15 | export function generateTemplateCache(src: string[], dest: string, basePath: string, eol: string) { 16 | if (!src.length) { 17 | return; 18 | } 19 | 20 | // Resolve the relative path from basePath to each src file 21 | var relativePaths: string[] = _.map(src, (anHtmlFile) => 'text!' + utils.makeRelativePath(basePath, anHtmlFile)); 22 | var fileNames: string[] = _.map(src, (anHtmlFile) => path.basename(anHtmlFile)); 23 | var fileVarialbeName = (anHtmlFile) => anHtmlFile.split('.').join('_').split('-').join('_'); 24 | var fileVariableNames: string[] = _.map(fileNames, fileVarialbeName); 25 | 26 | 27 | var templateCacheTemplate = _.template('// You must have requirejs + text plugin loaded for this to work.' 28 | + eol + 'define([<%=relativePathSection%>],function(<%=fileNameVariableSection%>){' 29 | + eol + 'angular.module("ng").run(["$templateCache",function($templateCache) {' 30 | + eol + '<%=templateCachePut%>' 31 | + eol + '}]);' 32 | + eol + '});'); 33 | 34 | var relativePathSection = '"' + relativePaths.join('",' + eol + '"') + '"'; 35 | var fileNameVariableSection = fileVariableNames.join(',' + eol); 36 | 37 | var templateCachePutTemplate = _.template('$templateCache.put("<%= fileName %>", <%=fileVariableName%>);'); 38 | var templateCachePut = _.map(fileNames, (fileName) => templateCachePutTemplate({ 39 | fileName: fileName, 40 | fileVariableName: fileVarialbeName(fileName) 41 | })).join(eol); 42 | 43 | var fileContent = templateCacheTemplate({ 44 | relativePathSection: relativePathSection, 45 | fileNameVariableSection: fileNameVariableSection, 46 | templateCachePut: templateCachePut 47 | }); 48 | 49 | // Early exit if new templateCache doesn't change 50 | if (fs.existsSync(dest)) { 51 | var originalContents = fs.readFileSync(dest).toString(); 52 | if (originalContents === fileContent) { 53 | return; 54 | } 55 | } 56 | 57 | // write updated contents 58 | fs.writeFileSync(dest, fileContent); 59 | } 60 | -------------------------------------------------------------------------------- /tasks-internal/modules/templateCache.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import _ = require('lodash'); 4 | import fs = require('fs'); 5 | import path = require('path'); 6 | 7 | import utils = require('./utils'); 8 | 9 | ///////////////////////////////////////////////////////////////////// 10 | // AngularJS templateCache 11 | //////////////////////////////////////////////////////////////////// 12 | 13 | // templateCache processing function 14 | 15 | export function generateTemplateCache(src: string[], dest: string, basePath: string, eol: string) { 16 | if (!src.length) { 17 | return; 18 | } 19 | 20 | // Resolve the relative path from basePath to each src file 21 | var relativePaths: string[] = _.map(src, (anHtmlFile) => 'text!' + utils.makeRelativePath(basePath, anHtmlFile)); 22 | var fileNames: string[] = _.map(src, (anHtmlFile) => path.basename(anHtmlFile)); 23 | var fileVarialbeName = (anHtmlFile) => anHtmlFile.split('.').join('_').split('-').join('_'); 24 | var fileVariableNames: string[] = _.map(fileNames, fileVarialbeName); 25 | 26 | 27 | var templateCacheTemplate = _.template('// You must have requirejs + text plugin loaded for this to work.' 28 | + eol + 'define([<%=relativePathSection%>],function(<%=fileNameVariableSection%>){' 29 | + eol + 'angular.module("ng").run(["$templateCache",function($templateCache) {' 30 | + eol + '<%=templateCachePut%>' 31 | + eol + '}]);' 32 | + eol + '});'); 33 | 34 | var relativePathSection = '"' + relativePaths.join('",' + eol + '"') + '"'; 35 | var fileNameVariableSection = fileVariableNames.join(',' + eol); 36 | 37 | var templateCachePutTemplate = _.template('$templateCache.put("<%= fileName %>", <%=fileVariableName%>);'); 38 | var templateCachePut = _.map(fileNames, (fileName) => templateCachePutTemplate({ 39 | fileName: fileName, 40 | fileVariableName: fileVarialbeName(fileName) 41 | })).join(eol); 42 | 43 | var fileContent = templateCacheTemplate({ 44 | relativePathSection: relativePathSection, 45 | fileNameVariableSection: fileNameVariableSection, 46 | templateCachePut: templateCachePut 47 | }); 48 | 49 | // Early exit if new templateCache doesn't change 50 | if (fs.existsSync(dest)) { 51 | var originalContents = fs.readFileSync(dest).toString(); 52 | if (originalContents === fileContent) { 53 | return; 54 | } 55 | } 56 | 57 | // write updated contents 58 | fs.writeFileSync(dest, fileContent); 59 | } 60 | -------------------------------------------------------------------------------- /tasks-internal/modules/templateCache.js: -------------------------------------------------------------------------------- 1 | /// 2 | "use strict"; 3 | var _ = require("lodash"); 4 | var fs = require("fs"); 5 | var path = require("path"); 6 | var utils = require("./utils"); 7 | ///////////////////////////////////////////////////////////////////// 8 | // AngularJS templateCache 9 | //////////////////////////////////////////////////////////////////// 10 | // templateCache processing function 11 | function generateTemplateCache(src, dest, basePath, eol) { 12 | if (!src.length) { 13 | return; 14 | } 15 | // Resolve the relative path from basePath to each src file 16 | var relativePaths = _.map(src, function (anHtmlFile) { return 'text!' + utils.makeRelativePath(basePath, anHtmlFile); }); 17 | var fileNames = _.map(src, function (anHtmlFile) { return path.basename(anHtmlFile); }); 18 | var fileVarialbeName = function (anHtmlFile) { return anHtmlFile.split('.').join('_').split('-').join('_'); }; 19 | var fileVariableNames = _.map(fileNames, fileVarialbeName); 20 | var templateCacheTemplate = _.template('// You must have requirejs + text plugin loaded for this to work.' 21 | + eol + 'define([<%=relativePathSection%>],function(<%=fileNameVariableSection%>){' 22 | + eol + 'angular.module("ng").run(["$templateCache",function($templateCache) {' 23 | + eol + '<%=templateCachePut%>' 24 | + eol + '}]);' 25 | + eol + '});'); 26 | var relativePathSection = '"' + relativePaths.join('",' + eol + '"') + '"'; 27 | var fileNameVariableSection = fileVariableNames.join(',' + eol); 28 | var templateCachePutTemplate = _.template('$templateCache.put("<%= fileName %>", <%=fileVariableName%>);'); 29 | var templateCachePut = _.map(fileNames, function (fileName) { return templateCachePutTemplate({ 30 | fileName: fileName, 31 | fileVariableName: fileVarialbeName(fileName) 32 | }); }).join(eol); 33 | var fileContent = templateCacheTemplate({ 34 | relativePathSection: relativePathSection, 35 | fileNameVariableSection: fileNameVariableSection, 36 | templateCachePut: templateCachePut 37 | }); 38 | // Early exit if new templateCache doesn't change 39 | if (fs.existsSync(dest)) { 40 | var originalContents = fs.readFileSync(dest).toString(); 41 | if (originalContents === fileContent) { 42 | return; 43 | } 44 | } 45 | // write updated contents 46 | fs.writeFileSync(dest, fileContent); 47 | } 48 | exports.generateTemplateCache = generateTemplateCache; 49 | //# sourceMappingURL=templateCache.js.map -------------------------------------------------------------------------------- /docs/DisableVisualStudioBuild.md: -------------------------------------------------------------------------------- 1 | # How to disable the Visual Studio TypeScript Build 2 | *but keep the TypeScript Project Properties Pane Working...* 3 | 4 | If you are using Visual Studio and wish to compile your TypeScript with grunt-ts *only*, you can disable the Visual Studio TypeScript build by performing the following steps: 5 | 6 | * First, make sure your project has TypeScript support enabled by opening the project properties and confirming that the TypeScript Build properties pane is selectable. 7 | * Next, make sure your project folder has grunt-ts installed, and confirm that running grunt with the appropriate configuration will compile your project correctly. 8 | * Exit Visual Studio (Targets are only read once, so unloading the project is not sufficient). 9 | * Make sure that your project is backed-up or fully checked-in to Source Control. 10 | * Edit the .csproj or .vbproj file for which you wish to disable VS TypeScript building. 11 | * Search for the line containing the text "Microsoft.TypeScript.targets". Delete or comment-out the entire line. 12 | * At that spot, add one of these lines: 13 | 14 | **If grunt-ts is installed in node_modules under the Project folder:** 15 | ```xml 16 | 17 | ``` 18 | 19 | **If grunt-ts is installed in node_modules under the Solution folder:** 20 | ```xml 21 | 22 | ``` 23 | 24 | **If grunt-ts is installed elsewhere** 25 | Modify one of the previous examples to point to the `custom.TypeScript.targets` file. 26 | 27 | * If you have multiple projects in your solution, you must edit each .csproj or .vbproj. 28 | * Reload Visual Studio and confirm that the TypeScript Build pane still appears in the project properties. 29 | * Then, introduce an error in a TypeScript file such as a mismatched parenthesis. 30 | * Finally, press Ctrl+Shift+B to initiate a build. If the build succeeds, you've successfully disabled the TypeScript compilation in Visual Studio. Run Grunt to build your project and it should fail. Fix the error and Grunt should then succeed (assuming it was prior to you making these changes). 31 | * Note that "Compile on Save" *will still work* with the Visual Studio TypeScript Build disabled. If you don't want Visual Studio to *ever* write TypeScript-emitted JavaScript files to disk, you will also need to disable "Compile on Save" in each project and configuration via the TypeScript Build pane. 32 | -------------------------------------------------------------------------------- /test/compilerTests.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var compile = require("../tasks/modules/compile"); 4 | exports.tests = { 5 | "grunt-ts `fast` compile feature": { 6 | "Successful compile with (fast === never) should NOT refresh fast cache": function (test) { 7 | test.expect(1); 8 | var options = { fast: "never" }, compileResult = { code: 0 }, result = compile.compileResultMeansFastCacheShouldBeRefreshed(options, compileResult); 9 | test.strictEqual(result, false); 10 | test.done(); 11 | }, 12 | "Successful compile with (fast === always) should refresh fast cache": function (test) { 13 | test.expect(1); 14 | var options = { fast: "always" }, compileResult = { code: 0 }, result = compile.compileResultMeansFastCacheShouldBeRefreshed(options, compileResult); 15 | test.strictEqual(result, true); 16 | test.done(); 17 | }, 18 | "Syntax error compile with (fast === never) should NOT refresh fast cache": function (test) { 19 | test.expect(1); 20 | var options = { fast: "never" }, compileResult = { code: 1 }, result = compile.compileResultMeansFastCacheShouldBeRefreshed(options, compileResult); 21 | test.strictEqual(result, false); 22 | test.done(); 23 | }, 24 | "Syntax error compile with (fast === always) should NOT refresh fast cache": function (test) { 25 | test.expect(1); 26 | var options = { fast: "always" }, compileResult = { code: 1 }, result = compile.compileResultMeansFastCacheShouldBeRefreshed(options, compileResult); 27 | test.strictEqual(result, false); 28 | test.done(); 29 | }, 30 | "Type error compile with (fast === always) and !failOnTypeErrors should refresh fast cache": function (test) { 31 | test.expect(1); 32 | var options = { fast: "always", failOnTypeErrors: false }, compileResult = { code: 2 }, result = compile.compileResultMeansFastCacheShouldBeRefreshed(options, compileResult); 33 | test.strictEqual(result, true); 34 | test.done(); 35 | }, 36 | "Type error compile with (fast === always) and failOnTypeErrors should NOT refresh fast cache": function (test) { 37 | test.expect(1); 38 | var options = { fast: "always", failOnTypeErrors: true }, compileResult = { code: 2 }, result = compile.compileResultMeansFastCacheShouldBeRefreshed(options, compileResult); 39 | test.strictEqual(result, false); 40 | test.done(); 41 | } 42 | } 43 | }; 44 | //# sourceMappingURL=compilerTests.js.map -------------------------------------------------------------------------------- /docs/amdLoader.md: -------------------------------------------------------------------------------- 1 | ## DEPRECATED. 2 | Please use [Transforms](https://github.com/grunt-ts/grunt-ts#transforms) in new projects. 3 | 4 | ### AMD / RequireJS support 5 | 6 | When both `outDir` and `amdloader` options are specified a JavaScript requireJS loader file is created using the information available from `reference.ts`. 7 | 8 | The file consists of three sections.: 9 | 10 | * The initial ordered section. 11 | * A middle order independent section loaded asynchronously. 12 | * And a final ordered section. 13 | 14 | E.g the following `reference` file: 15 | 16 | ```typescript 17 | /// 18 | 19 | //grunt-start 20 | /// 21 | /// 22 | //grunt-end 23 | 24 | /// 25 | /// 26 | ``` 27 | 28 | This corresponds to an `amdloader` (edited for readability): 29 | 30 | ```typescript 31 | // initial ordered files 32 | define(function (require) { 33 | require(["./classa"],function () { 34 | // grunt-ts start 35 | require(["./deep/classb", 36 | "./deep/classc"],function () { 37 | // grunt-ts end 38 | // final ordered files 39 | require(["./deep/deeper/classd"],function () { 40 | require(["./app"],function () { 41 | // final ordered file loaded 42 | }); 43 | }); 44 | }); 45 | }); 46 | }); 47 | ``` 48 | 49 | ### Advantage of using amdloader option 50 | 51 | The following combination of circumstances are the main use-case for amdloader compared to the original Compiler supported AMD: 52 | 53 | * Use RequireJS since allows to debug "js" files instead of "ts" files. This is useful in some cases, the most common way is using AMD. 54 | * Keep the ability to individually compile only changed files (for a faster dev-compile-run cycle) 55 | * However, File order doesn't matter, even when there is a inter file depenendency (e.g. AngularJS runtime Dependency injection) 56 | 57 | In such a case it is possible to either create a `loader.js` manually or have grunt create one. 58 | 59 | **Further Explanation** When using `export class Foo{}` at the root level of the file the only way to use the type information of Foo in another file is via an import statement: `import foo = require('./potentially/long/path/to/Foo');`. 60 | 61 | The ordering implied by this isn't necessary when using a runtime Dependency Injection framework like AngularJS. 62 | 63 | Having a loader gives the js debugging (+ async) advantages of RequireJS without the overhead of constantly requesting via `import` to get the TypeScript type inference and worrying about file paths when they are not relevant. 64 | 65 | Note: the individual file source-map will continue to work so it is possible to debug individual "JS" or "TS" files :) 66 | -------------------------------------------------------------------------------- /test/compilerTests.ts: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | import * as nodeunit from 'nodeunit'; 3 | import * as compile from '../tasks/modules/compile'; 4 | 5 | export const tests : nodeunit.ITestGroup = { 6 | "grunt-ts `fast` compile feature": { 7 | "Successful compile with (fast === never) should NOT refresh fast cache": (test: nodeunit.Test) => { 8 | test.expect(1); 9 | const options: IGruntTSOptions = {fast: "never"}, 10 | compileResult: ICompileResult = {code: 0}, 11 | result = compile.compileResultMeansFastCacheShouldBeRefreshed(options, compileResult); 12 | 13 | test.strictEqual(result, false); 14 | test.done(); 15 | }, 16 | "Successful compile with (fast === always) should refresh fast cache": (test: nodeunit.Test) => { 17 | test.expect(1); 18 | const options: IGruntTSOptions = {fast: "always"}, 19 | compileResult: ICompileResult = {code: 0}, 20 | result = compile.compileResultMeansFastCacheShouldBeRefreshed(options, compileResult); 21 | 22 | test.strictEqual(result, true); 23 | test.done(); 24 | }, 25 | "Syntax error compile with (fast === never) should NOT refresh fast cache": (test: nodeunit.Test) => { 26 | test.expect(1); 27 | const options: IGruntTSOptions = {fast: "never"}, 28 | compileResult: ICompileResult = {code: 1}, 29 | result = compile.compileResultMeansFastCacheShouldBeRefreshed(options, compileResult); 30 | 31 | test.strictEqual(result, false); 32 | test.done(); 33 | }, 34 | "Syntax error compile with (fast === always) should NOT refresh fast cache": (test: nodeunit.Test) => { 35 | test.expect(1); 36 | const options: IGruntTSOptions = {fast: "always"}, 37 | compileResult: ICompileResult = {code: 1}, 38 | result = compile.compileResultMeansFastCacheShouldBeRefreshed(options, compileResult); 39 | 40 | test.strictEqual(result, false); 41 | test.done(); 42 | }, 43 | "Type error compile with (fast === always) and !failOnTypeErrors should refresh fast cache": (test: nodeunit.Test) => { 44 | test.expect(1); 45 | const options: IGruntTSOptions = {fast: "always", failOnTypeErrors: false}, 46 | compileResult: ICompileResult = {code: 2}, 47 | result = compile.compileResultMeansFastCacheShouldBeRefreshed(options, compileResult); 48 | 49 | test.strictEqual(result, true); 50 | test.done(); 51 | }, 52 | "Type error compile with (fast === always) and failOnTypeErrors should NOT refresh fast cache": (test: nodeunit.Test) => { 53 | test.expect(1); 54 | const options: IGruntTSOptions = {fast: "always", failOnTypeErrors: true}, 55 | compileResult: ICompileResult = {code: 2}, 56 | result = compile.compileResultMeansFastCacheShouldBeRefreshed(options, compileResult); 57 | 58 | test.strictEqual(result, false); 59 | test.done(); 60 | } 61 | } 62 | }; 63 | -------------------------------------------------------------------------------- /tasks/modules/reference.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var _ = require("lodash"); 4 | var fs = require("fs"); 5 | var grunt = require("grunt"); 6 | var utils = require("./utils"); 7 | function updateReferenceFile(files, generatedFiles, referenceFile, referencePath, eol) { 8 | var referenceIntro = '/// '; 10 | var referenceMatch = /\/\/\/ ', // Template for module name for generated ts from html files [(default) '<%= filename %>'] 19 | htmlVarTemplate: '<%= ext %>', // Template for variable name used in generated ts from html files [(default) '<%= ext %>] 20 | // Both html templates accept the ext and filename parameters. 21 | noImplicitAny: false, // set to true to pass --noImplicitAny to the compiler. [true | false (default)] 22 | fast: "watch" // see https://github.com/TypeStrong/grunt-ts/blob/master/docs/fast.md ["watch" (default) | "always" | "never"] 23 | /* ,compiler: './node_modules/grunt-ts/customcompiler/tsc' */ //will use the specified compiler. 24 | }, 25 | // a particular target 26 | dev: { 27 | src: ["app/**/*.ts"], // The source typescript files, http://gruntjs.com/configuring-tasks#files 28 | html: ['app/**/**.tpl.html'], // The source html files, https://github.com/basarat/grunt-ts#html-2-typescript-support 29 | reference: 'app/reference.ts', // If specified, generate this file that you can use for your reference management 30 | out: 'app/out.js', // If specified, generate an out.js file which is the merged js file 31 | watch: 'app', // If specified, watches this directory for changes, and re-runs the current target 32 | // use to override the grunt-ts project options above for this target 33 | options: { 34 | module: 'commonjs' 35 | } 36 | } 37 | } 38 | }); 39 | 40 | grunt.loadNpmTasks("grunt-ts"); 41 | grunt.registerTask("default", ["ts:dev"]); 42 | }; 43 | -------------------------------------------------------------------------------- /tasks/modules/html2ts.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var _ = require("lodash"); 4 | var fs = require("fs"); 5 | var path = require("path"); 6 | var utils = require("./utils"); 7 | var grunt = utils.grunt; 8 | var escapeContent = function (content, quoteChar) { 9 | if (quoteChar === void 0) { quoteChar = '\''; } 10 | var quoteRegexp = new RegExp('\\' + quoteChar, 'g'); 11 | var nlReplace = ''; 12 | return content.replace(quoteRegexp, '\\' + quoteChar).replace(/\r?\n/g, nlReplace); 13 | }; 14 | var toCamel = function (str) { 15 | return str.replace(/(\-[a-z])/g, function ($1) { return $1.toUpperCase().replace('-', ''); }); 16 | }; 17 | function stripBOM(str) { 18 | return 0xFEFF === str.charCodeAt(0) 19 | ? str.substring(1) 20 | : str; 21 | } 22 | function htmlInternalTemplate(lineEnding) { 23 | return '/* tslint:disable:max-line-length */' + lineEnding + 24 | 'module <%= modulename %> {' + lineEnding + 25 | ' export var <%= varname %> = \'<%= content %>\';' + lineEnding + 26 | '}' + lineEnding; 27 | } 28 | ; 29 | function compileHTML(filename, options) { 30 | grunt.log.verbose.writeln('Compiling HTML: ' + filename); 31 | var htmlContent = escapeContent(fs.readFileSync(filename).toString()); 32 | htmlContent = stripBOM(htmlContent); 33 | var ext = path.extname(filename).replace('.', ''); 34 | var extFreename = path.basename(filename, '.' + ext); 35 | var moduleName = toCamel(options.moduleFunction({ ext: ext, filename: extFreename })); 36 | var varName = toCamel(options.varFunction({ ext: ext, filename: extFreename }).replace(/\./g, '_')); 37 | var fileContent; 38 | if (!options.htmlOutputTemplate) { 39 | fileContent = _.template(htmlInternalTemplate(options.eol))({ modulename: moduleName, varname: varName, content: htmlContent }); 40 | } 41 | else { 42 | fileContent = _.template(replaceNewLines(options.htmlOutputTemplate, options.eol))({ modulename: moduleName, varname: varName, content: htmlContent }); 43 | } 44 | var outputfile = getOutputFile(filename, options.htmlOutDir, options.flatten); 45 | mkdirParent(path.dirname(outputfile)); 46 | fs.writeFileSync(outputfile, fileContent); 47 | return outputfile; 48 | } 49 | exports.compileHTML = compileHTML; 50 | function replaceNewLines(input, newLines) { 51 | return input.replace(/\r/g, '').replace(/\n/g, newLines); 52 | } 53 | function getOutputFile(filename, htmlOutDir, flatten) { 54 | var outputfile = filename; 55 | if (htmlOutDir !== null) { 56 | var dir = getPath(htmlOutDir); 57 | if (fs.existsSync(dir)) { 58 | var relativeFilename = filename; 59 | if (flatten) { 60 | relativeFilename = path.basename(filename); 61 | } 62 | outputfile = path.join(dir, relativeFilename); 63 | } 64 | } 65 | return outputfile + '.ts'; 66 | } 67 | function getPath(dir) { 68 | if (!fs.existsSync(dir)) { 69 | dir = path.join(process.cwd(), dir); 70 | } 71 | return dir; 72 | } 73 | function mkdirParent(dirPath, mode) { 74 | try { 75 | fs.mkdirSync(dirPath, mode); 76 | } 77 | catch (error) { 78 | if (error && error.errno === 34) { 79 | mkdirParent(path.dirname(dirPath), mode); 80 | mkdirParent(dirPath, mode); 81 | } 82 | } 83 | } 84 | //# sourceMappingURL=html2ts.js.map -------------------------------------------------------------------------------- /tasks/modules/defaults.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var utils = require("./utils"); 4 | var _ = require("lodash"); 5 | var TypeScriptDefaults = { 6 | additionalFlags: '', 7 | allowBool: false, 8 | allowImportModule: false, 9 | allowJs: false, 10 | allowSyntheticDefaultImports: null, 11 | allowUnreachableCode: false, 12 | allowUnusedLabels: false, 13 | alwaysStrict: false, 14 | amdloader: null, 15 | baseUrl: null, 16 | charset: null, 17 | checkJs: false, 18 | comments: null, 19 | compile: true, 20 | compiler: '', 21 | declaration: false, 22 | declarationDir: null, 23 | diagnostics: false, 24 | disableSizeLimit: false, 25 | downlevelIteration: false, 26 | emitBOM: false, 27 | emitDecoratorMetadata: false, 28 | emitGruntEvents: null, 29 | esModuleInterop: false, 30 | errors: [], 31 | experimentalAsyncFunctions: null, 32 | experimentalDecorators: false, 33 | failOnTypeErrors: null, 34 | fast: null, 35 | forceCompileRegex: null, 36 | forceConsistentCasingInFileNames: false, 37 | html: null, 38 | htmlModuleTemplate: null, 39 | htmlOutDir: null, 40 | htmlOutDirFlatten: null, 41 | htmlOutputTemplate: null, 42 | htmlVarTemplate: null, 43 | inlineSourceMap: false, 44 | inlineSources: false, 45 | importHelpers: false, 46 | isolatedModules: false, 47 | jsx: null, 48 | jsxFactory: null, 49 | lib: null, 50 | listEmittedFiles: false, 51 | listFiles: false, 52 | locale: null, 53 | mapRoot: '', 54 | maxNodeModuleJsDepth: null, 55 | module: null, 56 | moduleResolution: null, 57 | newLine: utils.eol, 58 | noEmit: false, 59 | noEmitHelpers: false, 60 | noEmitOnError: false, 61 | noFallthroughCasesInSwitch: false, 62 | noImplicitAny: false, 63 | noImplicitReturns: false, 64 | noImplicitThis: false, 65 | noImplicitUseStrict: false, 66 | noLib: false, 67 | noResolve: false, 68 | noStrictGenericChecks: false, 69 | noUnusedLocals: false, 70 | noUnusedParameters: false, 71 | preserveConstEnums: false, 72 | preserveSymlinks: false, 73 | pretty: false, 74 | reactNamespace: null, 75 | removeComments: null, 76 | rootDir: null, 77 | skipDefaultLibCheck: false, 78 | skipLibCheck: false, 79 | sourceMap: true, 80 | sourceRoot: '', 81 | strict: false, 82 | strictFunctionTypes: false, 83 | strictNullChecks: false, 84 | strictPropertyInitialization: false, 85 | stripInternal: false, 86 | suppressExcessPropertyErrors: false, 87 | suppressImplicitAnyIndexErrors: false, 88 | target: null, 89 | targetName: '', 90 | templateCache: null, 91 | traceResolution: false, 92 | tsCacheDir: '', 93 | types: null, 94 | typeRoots: null, 95 | verbose: false, 96 | warnings: [], 97 | watch: null 98 | }; 99 | exports.GruntTSDefaults = applyGruntTSDefaults(_.clone(TypeScriptDefaults)); 100 | function applyGruntTSDefaults(options) { 101 | options.sourceMap = true; 102 | options.target = 'es5'; 103 | options.htmlModuleTemplate = '<%= filename %>'; 104 | options.htmlVarTemplate = '<%= ext %>'; 105 | options.htmlOutDirFlatten = false; 106 | options.fast = 'watch'; 107 | options.removeComments = true; 108 | options.failOnTypeErrors = true; 109 | options.emitGruntEvents = false; 110 | options.tsCacheDir = '.tscache'; 111 | return options; 112 | } 113 | //# sourceMappingURL=defaults.js.map -------------------------------------------------------------------------------- /tasks/modules/defaults.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import * as utils from './utils'; 4 | import * as _ from 'lodash'; 5 | 6 | const TypeScriptDefaults: IGruntTSOptions = { 7 | additionalFlags: '', 8 | allowBool: false, 9 | allowImportModule: false, 10 | allowJs: false, 11 | allowSyntheticDefaultImports: null, 12 | allowUnreachableCode: false, 13 | allowUnusedLabels: false, 14 | alwaysStrict: false, 15 | amdloader: null, 16 | baseUrl: null, 17 | charset: null, 18 | checkJs: false, 19 | comments: null, 20 | compile: true, 21 | compiler: '', 22 | declaration: false, 23 | declarationDir: null, 24 | diagnostics: false, 25 | disableSizeLimit: false, 26 | downlevelIteration: false, 27 | emitBOM: false, 28 | emitDecoratorMetadata: false, 29 | emitGruntEvents: null, 30 | esModuleInterop: false, 31 | errors: [], 32 | experimentalAsyncFunctions: null, 33 | experimentalDecorators: false, 34 | failOnTypeErrors: null, 35 | fast: null, 36 | forceCompileRegex: null, 37 | forceConsistentCasingInFileNames: false, 38 | html: null, 39 | htmlModuleTemplate: null, 40 | htmlOutDir: null, 41 | htmlOutDirFlatten: null, 42 | htmlOutputTemplate: null, 43 | htmlVarTemplate: null, 44 | inlineSourceMap: false, 45 | inlineSources: false, 46 | importHelpers: false, 47 | isolatedModules: false, 48 | jsx: null, 49 | jsxFactory: null, 50 | lib: null, 51 | listEmittedFiles: false, 52 | listFiles: false, 53 | locale: null, 54 | mapRoot: '', 55 | maxNodeModuleJsDepth: null, 56 | module: null, 57 | moduleResolution: null, 58 | newLine: utils.eol, 59 | noEmit: false, 60 | noEmitHelpers: false, 61 | noEmitOnError: false, 62 | noFallthroughCasesInSwitch: false, 63 | noImplicitAny: false, 64 | noImplicitReturns: false, 65 | noImplicitThis: false, 66 | noImplicitUseStrict: false, 67 | noLib: false, 68 | noResolve: false, 69 | noStrictGenericChecks: false, 70 | noUnusedLocals: false, 71 | noUnusedParameters: false, 72 | preserveConstEnums: false, 73 | preserveSymlinks: false, 74 | pretty: false, 75 | reactNamespace: null, 76 | removeComments: null, 77 | rootDir: null, 78 | skipDefaultLibCheck: false, 79 | skipLibCheck: false, 80 | sourceMap: true, 81 | sourceRoot: '', 82 | strict: false, 83 | strictFunctionTypes: false, 84 | strictNullChecks: false, 85 | strictPropertyInitialization: false, 86 | stripInternal: false, 87 | suppressExcessPropertyErrors: false, 88 | suppressImplicitAnyIndexErrors: false, 89 | target: null, 90 | targetName: '', 91 | templateCache: null, 92 | traceResolution: false, 93 | tsCacheDir: '', 94 | types: null, 95 | typeRoots: null, 96 | verbose: false, 97 | warnings: [], 98 | watch: null 99 | }; 100 | 101 | 102 | export const GruntTSDefaults = applyGruntTSDefaults(_.clone(TypeScriptDefaults)); 103 | 104 | function applyGruntTSDefaults(options: IGruntTSOptions) { 105 | // this function applies defaults where grunt-ts differs from TypeScript 106 | options.sourceMap = true; 107 | options.target = 'es5'; 108 | options.htmlModuleTemplate = '<%= filename %>'; 109 | options.htmlVarTemplate = '<%= ext %>'; 110 | options.htmlOutDirFlatten = false; 111 | options.fast = 'watch'; 112 | options.removeComments = true; 113 | options.failOnTypeErrors = true; 114 | options.emitGruntEvents = false; 115 | options.tsCacheDir = '.tscache'; 116 | return options; 117 | } 118 | -------------------------------------------------------------------------------- /tasks/modules/cacheUtils.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var fs = require("fs"); 4 | var _ = require("lodash"); 5 | var path = require("path"); 6 | var crypto = require("crypto"); 7 | var grunt = require('grunt'); 8 | var rimraf = require('rimraf'); 9 | function getStampPath(targetName, cacheDir) { 10 | return path.join(cacheDir, targetName, 'timestamp'); 11 | } 12 | function getLastSuccessfullCompile(targetName, cacheDir) { 13 | var stampFile = getStampPath(targetName, cacheDir); 14 | try { 15 | return fs.statSync(stampFile).mtime; 16 | } 17 | catch (err) { 18 | return new Date(0); 19 | } 20 | } 21 | function getFilesNewerThan(paths, time) { 22 | var filtered = _.filter(paths, function (path) { 23 | var stats = fs.statSync(path); 24 | return stats.mtime > time; 25 | }); 26 | return filtered; 27 | } 28 | function anyNewerThan(paths, time) { 29 | return getFilesNewerThan(paths, time).length > 0; 30 | } 31 | exports.anyNewerThan = anyNewerThan; 32 | function filterPathsByTime(paths, targetName, cacheDir) { 33 | var time = getLastSuccessfullCompile(targetName, cacheDir); 34 | return getFilesNewerThan(paths, time); 35 | } 36 | exports.filterPathsByTime = filterPathsByTime; 37 | function getHashPath(filePath, targetName, cacheDir) { 38 | var hashedName = path.basename(filePath) + '-' + crypto.createHash('md5').update(filePath).digest('hex'); 39 | return path.join(cacheDir, targetName, 'hashes', hashedName); 40 | } 41 | function getExistingHash(filePath, targetName, cacheDir) { 42 | var hashPath = getHashPath(filePath, targetName, cacheDir); 43 | var exists = fs.existsSync(hashPath); 44 | if (!exists) { 45 | return null; 46 | } 47 | return fs.readFileSync(hashPath).toString(); 48 | } 49 | function generateFileHash(filePath) { 50 | var md5sum = crypto.createHash('md5'); 51 | var data = fs.readFileSync(filePath); 52 | md5sum.update(data); 53 | return md5sum.digest('hex'); 54 | } 55 | function filterPathsByHash(filePaths, targetName, cacheDir) { 56 | var filtered = _.filter(filePaths, function (filePath) { 57 | var previous = getExistingHash(filePath, targetName, cacheDir); 58 | var current = generateFileHash(filePath); 59 | return previous !== current; 60 | }); 61 | return filtered; 62 | } 63 | function updateHashes(filePaths, targetName, cacheDir) { 64 | _.forEach(filePaths, function (filePath) { 65 | var hashPath = getHashPath(filePath, targetName, cacheDir); 66 | var hash = generateFileHash(filePath); 67 | grunt.file.write(hashPath, hash); 68 | }); 69 | } 70 | function getNewFilesForTarget(paths, targetName, cacheDir) { 71 | var step1 = filterPathsByTime(paths, targetName, cacheDir); 72 | var step2 = filterPathsByHash(step1, targetName, cacheDir); 73 | return step2; 74 | } 75 | exports.getNewFilesForTarget = getNewFilesForTarget; 76 | function compileSuccessfull(paths, targetName, cacheDir) { 77 | grunt.file.write(getStampPath(targetName, cacheDir), ''); 78 | updateHashes(paths, targetName, cacheDir); 79 | } 80 | exports.compileSuccessfull = compileSuccessfull; 81 | function clearCache(targetName, cacheDir) { 82 | var cacheDirForTarget = path.join(cacheDir, targetName); 83 | try { 84 | if (fs.existsSync(cacheDirForTarget)) { 85 | rimraf.sync(cacheDirForTarget); 86 | grunt.log.writeln(('Cleared fast compile cache for target: ' + targetName).cyan); 87 | } 88 | } 89 | catch (ex) { 90 | grunt.log.writeln(('Failed to clear compile cache for target: ' + targetName).red); 91 | } 92 | } 93 | exports.clearCache = clearCache; 94 | //# sourceMappingURL=cacheUtils.js.map -------------------------------------------------------------------------------- /test/test.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | var grunt: IGrunt = require('grunt'); 4 | import * as nodeunit from 'nodeunit'; 5 | 6 | import { 7 | assertFileDoesNotExist, 8 | testDirectory, 9 | testFile, 10 | testExpectedFile 11 | } from './testHelpers'; 12 | 13 | export var tests : nodeunit.ITestGroup = { 14 | setUp: (callback) => { 15 | callback(); 16 | }, 17 | tearDown: (callback) => { 18 | callback(); 19 | }, 20 | simple: function (test) { 21 | testFile(test, 'simple/js/zoo.js', true); 22 | testFile(test, 'simple/js/zoo.d.ts'); 23 | test.done(); 24 | }, 25 | simple_with_rootDir: function (test) { 26 | testDirectory(test, 'simple_with_rootDir'); 27 | test.done(); 28 | }, 29 | abtest: function (test) { 30 | testFile(test, 'abtest/reference.ts'); 31 | testFile(test, 'abtest/out.js', true); 32 | test.done(); 33 | }, 34 | allowJs: function (test) { 35 | testDirectory(test, 'allowJs'); 36 | test.done(); 37 | }, 38 | amdloader: function (test) { 39 | testDirectory(test, 'amdloader'); 40 | test.done(); 41 | }, 42 | templateCache: function (test) { 43 | testDirectory(test, 'templateCache'); 44 | test.done(); 45 | }, 46 | html2ts: function (test) { 47 | testDirectory(test, 'html'); 48 | testDirectory(test, 'htmlTemplate'); 49 | testDirectory(test, 'htmlSnakeModuleName'); 50 | test.done(); 51 | }, 52 | index: function (test) { 53 | testDirectory(test, 'index'); 54 | test.done(); 55 | }, 56 | transform: function (test) { 57 | testDirectory(test, 'transform', true); 58 | test.done(); 59 | }, 60 | referencesTransform: function (test) { 61 | testDirectory(test, 'references-transform'); 62 | test.done(); 63 | }, 64 | customcompiler: function (test) { 65 | testDirectory(test, 'customcompiler'); 66 | test.done(); 67 | }, 68 | fail: function (test) { 69 | testDirectory(test, 'fail'); // tested to make sure transformers still run for failing task 70 | test.done(); 71 | }, 72 | es6: function (test) { 73 | testDirectory(test, 'es6'); 74 | test.done(); 75 | }, 76 | noEmitOnError: function (test) { 77 | testDirectory(test, 'noEmitOnError'); 78 | assertFileDoesNotExist(test, 'test/noEmitOnError/testNoEmitOnError_true.js'); 79 | test.done(); 80 | }, 81 | preserveConstEnums: function (test) { 82 | testDirectory(test, 'preserveConstEnums'); 83 | test.done(); 84 | }, 85 | suppressImplicitAnyIndexErrors: function (test) { 86 | testDirectory(test, 'suppressImplicitAnyIndexErrors'); 87 | assertFileDoesNotExist(test, 'test/suppressImplicitAnyIndexErrors/test_suppressImplicitAnyIndexError_false.js'); 88 | test.done(); 89 | }, 90 | varReplacedTest: function (test) { 91 | testDirectory(test, 'varreplacedtest'); 92 | test.done(); 93 | }, 94 | vsproj_test_ignoreSettings: function (test) { 95 | testDirectory(test, 'vsproj/ignoreSettings'); 96 | test.done(); 97 | }, 98 | files_ObjectFormat: function (test) { 99 | testDirectory(test, 'files_ObjectFormat', true); 100 | test.done(); 101 | }, 102 | out_and_outdir_with_spaces: function (test) { 103 | testDirectory(test, 'out with spaces'); 104 | test.done(); 105 | }, 106 | htmlExternal: function (test) { 107 | testDirectory(test, 'htmlExternal'); 108 | test.done(); 109 | }, 110 | nestedSources: function (test) { 111 | testDirectory(test, 'nestedSources'); 112 | test.done(); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /test/vsproj/testproject.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | {FF8D9288-C427-4139-B162-E74D73D8F8D5} 6 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} 7 | Library 8 | bin 9 | v4.5 10 | full 11 | true 12 | true 13 | 14 | 15 | 16 | 17 | 18 | 19 | 12.0 20 | 21 | 22 | grunt_ts 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | True 31 | True 32 | 10690 33 | / 34 | http://localhost:10690/ 35 | False 36 | False 37 | 38 | 39 | False 40 | 41 | 42 | 43 | 44 | 45 | false 46 | true 47 | commonjs 48 | vsproj_test 49 | true 50 | true 51 | true 52 | true 53 | 54 | 55 | true 56 | false 57 | vsproj_test_config 58 | 59 | 60 | test_out.js 61 | 62 | 63 | 64 | 65 | 66 | ES3 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | var grunt = require('grunt'); 4 | var testHelpers_1 = require("./testHelpers"); 5 | exports.tests = { 6 | setUp: function (callback) { 7 | callback(); 8 | }, 9 | tearDown: function (callback) { 10 | callback(); 11 | }, 12 | simple: function (test) { 13 | testHelpers_1.testFile(test, 'simple/js/zoo.js', true); 14 | testHelpers_1.testFile(test, 'simple/js/zoo.d.ts'); 15 | test.done(); 16 | }, 17 | simple_with_rootDir: function (test) { 18 | testHelpers_1.testDirectory(test, 'simple_with_rootDir'); 19 | test.done(); 20 | }, 21 | abtest: function (test) { 22 | testHelpers_1.testFile(test, 'abtest/reference.ts'); 23 | testHelpers_1.testFile(test, 'abtest/out.js', true); 24 | test.done(); 25 | }, 26 | allowJs: function (test) { 27 | testHelpers_1.testDirectory(test, 'allowJs'); 28 | test.done(); 29 | }, 30 | amdloader: function (test) { 31 | testHelpers_1.testDirectory(test, 'amdloader'); 32 | test.done(); 33 | }, 34 | templateCache: function (test) { 35 | testHelpers_1.testDirectory(test, 'templateCache'); 36 | test.done(); 37 | }, 38 | html2ts: function (test) { 39 | testHelpers_1.testDirectory(test, 'html'); 40 | testHelpers_1.testDirectory(test, 'htmlTemplate'); 41 | testHelpers_1.testDirectory(test, 'htmlSnakeModuleName'); 42 | test.done(); 43 | }, 44 | index: function (test) { 45 | testHelpers_1.testDirectory(test, 'index'); 46 | test.done(); 47 | }, 48 | transform: function (test) { 49 | testHelpers_1.testDirectory(test, 'transform', true); 50 | test.done(); 51 | }, 52 | referencesTransform: function (test) { 53 | testHelpers_1.testDirectory(test, 'references-transform'); 54 | test.done(); 55 | }, 56 | customcompiler: function (test) { 57 | testHelpers_1.testDirectory(test, 'customcompiler'); 58 | test.done(); 59 | }, 60 | fail: function (test) { 61 | testHelpers_1.testDirectory(test, 'fail'); 62 | test.done(); 63 | }, 64 | es6: function (test) { 65 | testHelpers_1.testDirectory(test, 'es6'); 66 | test.done(); 67 | }, 68 | noEmitOnError: function (test) { 69 | testHelpers_1.testDirectory(test, 'noEmitOnError'); 70 | testHelpers_1.assertFileDoesNotExist(test, 'test/noEmitOnError/testNoEmitOnError_true.js'); 71 | test.done(); 72 | }, 73 | preserveConstEnums: function (test) { 74 | testHelpers_1.testDirectory(test, 'preserveConstEnums'); 75 | test.done(); 76 | }, 77 | suppressImplicitAnyIndexErrors: function (test) { 78 | testHelpers_1.testDirectory(test, 'suppressImplicitAnyIndexErrors'); 79 | testHelpers_1.assertFileDoesNotExist(test, 'test/suppressImplicitAnyIndexErrors/test_suppressImplicitAnyIndexError_false.js'); 80 | test.done(); 81 | }, 82 | varReplacedTest: function (test) { 83 | testHelpers_1.testDirectory(test, 'varreplacedtest'); 84 | test.done(); 85 | }, 86 | vsproj_test_ignoreSettings: function (test) { 87 | testHelpers_1.testDirectory(test, 'vsproj/ignoreSettings'); 88 | test.done(); 89 | }, 90 | files_ObjectFormat: function (test) { 91 | testHelpers_1.testDirectory(test, 'files_ObjectFormat', true); 92 | test.done(); 93 | }, 94 | out_and_outdir_with_spaces: function (test) { 95 | testHelpers_1.testDirectory(test, 'out with spaces'); 96 | test.done(); 97 | }, 98 | htmlExternal: function (test) { 99 | testHelpers_1.testDirectory(test, 'htmlExternal'); 100 | test.done(); 101 | }, 102 | nestedSources: function (test) { 103 | testHelpers_1.testDirectory(test, 'nestedSources'); 104 | test.done(); 105 | } 106 | }; 107 | //# sourceMappingURL=test.js.map -------------------------------------------------------------------------------- /tasks-internal/modules/reference.js: -------------------------------------------------------------------------------- 1 | /// 2 | "use strict"; 3 | var _ = require("lodash"); 4 | var fs = require("fs"); 5 | var grunt = require("grunt"); 6 | var utils = require("./utils"); 7 | ///////////////////////////////////////////////////////////////////// 8 | // Reference file logic 9 | //////////////////////////////////////////////////////////////////// 10 | // Updates the reference file 11 | function updateReferenceFile(files, generatedFiles, referenceFile, referencePath, eol) { 12 | var referenceIntro = '/// '; 14 | var referenceMatch = /\/\/\/ 2 | 3 | import _ = require('lodash'); 4 | import fs = require('fs'); 5 | import grunt = require('grunt'); 6 | 7 | import utils = require('./utils'); 8 | 9 | ///////////////////////////////////////////////////////////////////// 10 | // Reference file logic 11 | //////////////////////////////////////////////////////////////////// 12 | 13 | // Updates the reference file 14 | export function updateReferenceFile(files: string[], generatedFiles: string[], referenceFile: string, referencePath: string, eol: string): boolean { 15 | var referenceIntro = '/// '; 17 | var referenceMatch = /\/\/\/ referenceIntro + utils.makeRelativePath(referencePath, file) + referenceEnd); 77 | var contents = utils.insertArrayAt([ourSignatureStart], 1, generatedFiles); 78 | 79 | // Put in the new / observed missing files: 80 | files.forEach((filename: string) => { 81 | // The file we are about to add 82 | var filepath = utils.makeRelativePath(referencePath, filename); 83 | 84 | // If there are orig references 85 | if (origFileReferences.length) { 86 | if (_.includes(origFileReferences, filepath)) { 87 | return; 88 | } 89 | } 90 | 91 | // Finally add the filepath 92 | contents.push(referenceIntro + filepath + referenceEnd); 93 | }); 94 | contents.push(ourSignatureEnd); 95 | 96 | var updatedFileLines = utils.insertArrayAt(origFileLines, signatureSectionPosition, contents); 97 | var updatedFileContents = updatedFileLines.join(eol); 98 | 99 | // Modify the orig contents to put in our contents only if changed 100 | // Also Return whether the file was changed 101 | if (updatedFileContents !== referenceContents) { 102 | grunt.file.write(referenceFile, updatedFileContents); 103 | return true; 104 | } 105 | else { 106 | return false; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /tasks-internal/modules/reference.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import _ = require('lodash'); 4 | import fs = require('fs'); 5 | import grunt = require('grunt'); 6 | 7 | import utils = require('./utils'); 8 | 9 | ///////////////////////////////////////////////////////////////////// 10 | // Reference file logic 11 | //////////////////////////////////////////////////////////////////// 12 | 13 | // Updates the reference file 14 | export function updateReferenceFile(files: string[], generatedFiles: string[], referenceFile: string, referencePath: string, eol: string): boolean { 15 | var referenceIntro = '/// '; 17 | var referenceMatch = /\/\/\/ referenceIntro + utils.makeRelativePath(referencePath, file) + referenceEnd); 77 | var contents = utils.insertArrayAt([ourSignatureStart], 1, generatedFiles); 78 | 79 | // Put in the new / observed missing files: 80 | files.forEach((filename: string) => { 81 | // The file we are about to add 82 | var filepath = utils.makeRelativePath(referencePath, filename); 83 | 84 | // If there are orig references 85 | if (origFileReferences.length) { 86 | if (_.includes(origFileReferences, filepath)) { 87 | return; 88 | } 89 | } 90 | 91 | // Finally add the filepath 92 | contents.push(referenceIntro + filepath + referenceEnd); 93 | }); 94 | contents.push(ourSignatureEnd); 95 | 96 | var updatedFileLines = utils.insertArrayAt(origFileLines, signatureSectionPosition, contents); 97 | var updatedFileContents = updatedFileLines.join(eol); 98 | 99 | // Modify the orig contents to put in our contents only if changed 100 | // Also Return whether the file was changed 101 | if (updatedFileContents !== referenceContents) { 102 | grunt.file.write(referenceFile, updatedFileContents); 103 | return true; 104 | } 105 | else { 106 | return false; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /docs/html2ts.md: -------------------------------------------------------------------------------- 1 | ### Html 2 TypeScript support 2 | 3 | Grunt-ts can re-encode html files into TypeScript and make them available as a variable. 4 | 5 | For example a file called `test.html`: 6 | ```html 7 |
Some Content
8 | ``` 9 | 10 | Will be compiled to a TypeScript file `test.html.ts` containing: 11 | ```typescript 12 | module test { export var html = '
Some content
' } 13 | ``` 14 | 15 | This will export the variable `test.html` within the TypeScript scope to get the content of test.html as a string, with the main benefit of limiting the http-requests needed to load templates in various front-end frameworks. 16 | 17 | #### Html 2 TypeScript usage in AngularJS 18 | 19 | This is great for putting variables in templateCache: http://docs.angularjs.org/api/ng.$templateCache or even using the html string directly by setting it to the `template` properties (directives/views) instead of `templateUrl` 20 | 21 | #### Html 2 TypeScript usage in EmberJS 22 | 23 | It is possible to specify this string to the template on a view: http://emberjs.com/api/classes/Ember.View.html 24 | 25 | Specifically: http://stackoverflow.com/a/9867375/390330 26 | 27 | #### Control generated TypeScript module and variable names 28 | 29 | In the task options `htmlModuleTemplate` and `htmlVarTemplate` you can specify Underscore template variables to be used in order to generate the module and variable names for the generated TypeScript. 30 | 31 | Those Underscore template receive the following parameters: 32 | 33 | * filename - The html file name without the extension ("test" if the file was named test.html) 34 | * ext - The html extension without the dot ("html" if the file was named test.html) 35 | 36 | The default templates are: 37 | 38 | * "<%= filename %>" - for the module name. (This maintain existing behavior of older versions, and allow controlling the module name by simply renaming the file.) 39 | * "<%= ext %>" - for the variable name. (This maintain existing behavior of older versions, again allowing to control variable name by renaming the file.) 40 | 41 | Usage example is setting the module template to "MyModule.Templates" and the variable template to "<%= filename %>" this will result for the test.html file above with the generated TypeScript 42 | ```typescript 43 | module MyModule.Templates { export var test = '
' } 44 | ``` 45 | 46 | #### Override predefined template and specify a custom output format 47 | 48 | Using the task option `htmlOutputTemplate` you can specify Underscore template strings to be used against interpolation with three variables: 49 | 50 | * "<%= modulename %>" - This variable will be interpolated with the value of the htmlModuleTemplate option 51 | * "<%= varname %>" - This variable will be interpolated with the value of the htmlVarTemplate option 52 | * "<%= content %>" - This variable will be interpolated with the content of the HTML file 53 | 54 | 55 | For example if we would like to specify a custom template that outputs an external module, we could use: 56 | 57 | ````javascript 58 | //Note: Outputs an external module 59 | grunt.initConfig({ 60 | ts: { 61 | default: { 62 | options: { 63 | //HTML template objects will expose their content via a property called markup. 64 | htmlVarTemplate: 'markup', 65 | htmlModuleTemplate: 'html', 66 | htmlOutputTemplate: '/* tslint:disable:max-line-length */ \n\ 67 | export module <%= modulename %> {\n\ 68 | export var <%= varname %> = \'<%= content %>\';\n\ 69 | }\n' 70 | } 71 | } 72 | } 73 | }); 74 | ```` 75 | 76 | we can then do the following in our .ts file: 77 | 78 | ```typescript 79 | //import the external module 80 | import myTemplate = require('module'); 81 | 82 | //consume it 83 | var templateString = myTemplate.markup.html 84 | 85 | ``` 86 | 87 | 88 | If this appears as excessive object wrapping, the simplest form for htmlOutputTemplate is likely: 89 | 90 | ```javascript 91 | "export var <%= modulename %>='<%= content %>';" 92 | ``` 93 | 94 | #### Going further 95 | Primarily designed for html files, this feature can be used with any static file. 96 | 97 | For example a file called `license.txt`: 98 | ```txt 99 | Licensed under the MIT License. 100 | ``` 101 | 102 | Will be compiled to a TypeScript file `license.txt.ts` containing: 103 | ```typescript 104 | module test { export var html = 'Licensed under the MIT License.' } 105 | ``` 106 | -------------------------------------------------------------------------------- /tasks-internal/modules/html2ts.js: -------------------------------------------------------------------------------- 1 | /// 2 | "use strict"; 3 | var _ = require("lodash"); 4 | var fs = require("fs"); 5 | var path = require("path"); 6 | var utils = require("./utils"); 7 | var grunt = utils.grunt; 8 | ///////////////////////////////////////////////////////////////////// 9 | // HTML -> TS 10 | //////////////////////////////////////////////////////////////////// 11 | // html -> js processing functions: 12 | // Originally from karma-html2js-preprocessor 13 | // Refactored nicely in html2js grunt task 14 | // https://github.com/karlgoldstein/grunt-html2js/blob/master/tasks/html2js.js 15 | // Modified nlReplace to be an empty string 16 | var escapeContent = function (content, quoteChar) { 17 | if (quoteChar === void 0) { quoteChar = '\''; } 18 | var quoteRegexp = new RegExp('\\' + quoteChar, 'g'); 19 | var nlReplace = ''; 20 | return content.replace(quoteRegexp, '\\' + quoteChar).replace(/\r?\n/g, nlReplace); 21 | }; 22 | // Convert a string to camelCase 23 | // Inspired by http://jamesroberts.name/blog/2010/02/22/string-functions-for-javascript-trim-to-camel-case-to-dashed-and-to-underscore/ 24 | // Solves the issue of serving a module name that includes dashes 25 | var toCamel = function (str) { 26 | return str.replace(/(\-[a-z])/g, function ($1) { return $1.toUpperCase().replace('-', ''); }); 27 | }; 28 | // Remove bom when reading utf8 files 29 | function stripBOM(str) { 30 | return 0xFEFF === str.charCodeAt(0) 31 | ? str.substring(1) 32 | : str; 33 | } 34 | function htmlInternalTemplate(lineEnding) { 35 | return '/* tslint:disable:max-line-length */' + lineEnding + 36 | 'module <%= modulename %> {' + lineEnding + 37 | ' export var <%= varname %> = \'<%= content %>\';' + lineEnding + 38 | '}' + lineEnding; 39 | } 40 | ; 41 | // Compile an HTML file to a TS file 42 | // Return the filename. This filename will be required by reference.ts 43 | function compileHTML(filename, options) { 44 | grunt.log.verbose.writeln('Compiling HTML: ' + filename); 45 | var htmlContent = escapeContent(fs.readFileSync(filename).toString()); 46 | htmlContent = stripBOM(htmlContent); 47 | // TODO: place a minification pipeline here if you want. 48 | var ext = path.extname(filename).replace('.', ''); 49 | var extFreename = path.basename(filename, '.' + ext); 50 | var moduleName = toCamel(options.moduleFunction({ ext: ext, filename: extFreename })); 51 | var varName = toCamel(options.varFunction({ ext: ext, filename: extFreename }).replace(/\./g, '_')); 52 | var fileContent; 53 | if (!options.htmlOutputTemplate) { 54 | fileContent = _.template(htmlInternalTemplate(options.eol))({ modulename: moduleName, varname: varName, content: htmlContent }); 55 | } 56 | else { 57 | fileContent = _.template(replaceNewLines(options.htmlOutputTemplate, options.eol))({ modulename: moduleName, varname: varName, content: htmlContent }); 58 | } 59 | // Write the content to a file 60 | var outputfile = getOutputFile(filename, options.htmlOutDir, options.flatten); 61 | mkdirParent(path.dirname(outputfile)); 62 | fs.writeFileSync(outputfile, fileContent); 63 | return outputfile; 64 | } 65 | exports.compileHTML = compileHTML; 66 | // Replace user-supplied templates newlines with newlines appropriate for the current OS 67 | function replaceNewLines(input, newLines) { 68 | return input.replace(/\r/g, '').replace(/\n/g, newLines); 69 | } 70 | function getOutputFile(filename, htmlOutDir, flatten) { 71 | var outputfile = filename; 72 | // NOTE If an htmlOutDir was specified 73 | if (htmlOutDir !== null) { 74 | var dir = getPath(htmlOutDir); 75 | if (fs.existsSync(dir)) { 76 | var relativeFilename = filename; 77 | if (flatten) { 78 | relativeFilename = path.basename(filename); 79 | } 80 | outputfile = path.join(dir, relativeFilename); 81 | } 82 | } 83 | return outputfile + '.ts'; 84 | } 85 | function getPath(dir) { 86 | // NOTE If we don't have a valid absolute path 87 | if (!fs.existsSync(dir)) { 88 | // NOTE Try relative from the current working directory 89 | dir = path.join(process.cwd(), dir); 90 | } 91 | return dir; 92 | } 93 | function mkdirParent(dirPath, mode) { 94 | // NOTE Call the standard fs.mkdirSync 95 | try { 96 | fs.mkdirSync(dirPath, mode); 97 | } 98 | catch (error) { 99 | // NOTE When it fail in this way, do the custom steps 100 | if (error && error.errno === 34) { 101 | // NOTE Create all the parents recursively 102 | mkdirParent(path.dirname(dirPath), mode); 103 | // NOTE And then the directory 104 | mkdirParent(dirPath, mode); 105 | } 106 | } 107 | } 108 | //# sourceMappingURL=html2ts.js.map -------------------------------------------------------------------------------- /test/definitelytypedtest/d.ts/DefinitelyTyped/async/async.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for Async 0.1.23 2 | // Project: https://github.com/caolan/async 3 | // Definitions by: Boris Yankov 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | interface AsyncMultipleResultsCallback { (err: string, results: T[]): any; } 7 | interface AsyncSingleResultCallback { (err: string, result: T): any; } 8 | interface AsyncTimesCallback { (n: number, callback: AsyncMultipleResultsCallback): void; } 9 | interface AsyncIterator { (item: T, callback: AsyncMultipleResultsCallback): void; } 10 | interface AsyncMemoIterator { (memo: T, item: T, callback: AsyncSingleResultCallback): void; } 11 | interface AsyncWorker { (task: T, callback: Function): void; } 12 | 13 | interface AsyncQueue { 14 | length(): number; 15 | concurrency: number; 16 | push(task: T, callback: AsyncMultipleResultsCallback): void; 17 | saturated: AsyncMultipleResultsCallback; 18 | empty: AsyncMultipleResultsCallback; 19 | drain: AsyncMultipleResultsCallback; 20 | } 21 | 22 | interface Async { 23 | 24 | // Collections 25 | forEach(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): void; 26 | forEachSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): void; 27 | forEachLimit(arr: T[], limit: number, iterator: AsyncIterator, callback: AsyncMultipleResultsCallback): void; 28 | map(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); 29 | mapSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); 30 | filter(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); 31 | select(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); 32 | filterSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); 33 | selectSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); 34 | reject(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); 35 | rejectSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); 36 | reduce(arr: T[], memo: T, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback); 37 | inject(arr: T[], memo: T, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback); 38 | foldl(arr: T[], memo: T, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback); 39 | reduceRight(arr: T[], memo: T, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback); 40 | foldr(arr: T[], memo: T, iterator: AsyncMemoIterator, callback: AsyncSingleResultCallback); 41 | detect(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); 42 | detectSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); 43 | sortBy(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); 44 | some(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); 45 | any(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); 46 | every(arr: T[], iterator: AsyncIterator, callback: (result: boolean) => any); 47 | all(arr: T[], iterator: AsyncIterator, callback: (result: boolean) => any); 48 | concat(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); 49 | concatSeries(arr: T[], iterator: AsyncIterator, callback: AsyncMultipleResultsCallback); 50 | 51 | // Control Flow 52 | series(tasks: T[], callback?: AsyncMultipleResultsCallback): void; 53 | series(tasks: T, callback?: AsyncMultipleResultsCallback): void; 54 | parallel(tasks: T[], callback?: AsyncMultipleResultsCallback): void; 55 | parallel(tasks: T, callback?: AsyncMultipleResultsCallback): void; 56 | whilst(test: Function, fn: Function, callback: Function): void; 57 | until(test: Function, fn: Function, callback: Function): void; 58 | waterfall(tasks: T[], callback?: AsyncMultipleResultsCallback): void; 59 | waterfall(tasks: T, callback?: AsyncMultipleResultsCallback): void; 60 | queue(worker: AsyncWorker, concurrency: number): AsyncQueue; 61 | // auto(tasks: any[], callback?: AsyncMultipleResultsCallback): void; 62 | auto(tasks: any, callback?: AsyncMultipleResultsCallback): void; 63 | iterator(tasks: Function[]): Function; 64 | apply(fn: Function, ...arguments: any[]): void; 65 | nextTick(callback: Function): void; 66 | 67 | times (n: number, callback: AsyncTimesCallback): void; 68 | timesSeries (n: number, callback: AsyncTimesCallback): void; 69 | 70 | // Utils 71 | memoize(fn: Function, hasher?: Function): Function; 72 | unmemoize(fn: Function): Function; 73 | log(fn: Function, ...arguments: any[]): void; 74 | dir(fn: Function, ...arguments: any[]): void; 75 | noConflict(): Async; 76 | } 77 | 78 | declare var async: Async; 79 | 80 | declare module "async" { 81 | export = async; 82 | } --------------------------------------------------------------------------------