diff --git a/gruntfile.js b/gruntfile.js index 710e97235..2fb9f5c07 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -321,59 +321,6 @@ module.exports = function(grunt) { dest: "<%= grunt.option('path') %>/node_modules/tns-core-modules/", } }, - ts: { - build: { - tsconfig: { - tsconfig: 'tsconfig.json', - passThrough: true, - }, - outDir: localCfg.outDir, - dest: localCfg.outDir, - options: tsOptions - }, - buildNodeTests: { - src: [ - 'tns-core-modules/js-libs/easysax/**/*.ts', - 'tns-core-modules/module.d.ts', - 'tns-core-modules/xml/**/*.ts', - 'tns-core-modules/lib.core.d.ts', - 'tns-core-modules/lib.dom.d.ts', - 'tns-core-modules/es-collections.d.ts', - 'tns-core-modules/declarations.d.ts', - 'tns-core-modules/es6-promise.d.ts', - 'node-tests/**/*.ts' - ], - outDir: localCfg.outDir, - dest: localCfg.outDir, - options: tsOptions - }, - buildDts: { - src: [ - 'tns-core-modules/**/*.d.ts', - '!org.nativescript.widgets.d.ts', - '!**/*.android.d.ts', - '!**/node_modules/**/*', - '!**/platforms/**/*', - '!bin/**/*', - '!**/references.d.ts', - '!tns-core-modules/references.d.ts', - '!tns-core-modules/android17.d.ts', - '!tns-core-modules/ios/**/*', - '!tns-core-modules/org.nativescript.widgets.d.ts', - ], - outDir: localCfg.outDir, - dest: localCfg.outDir, - options: tsOptions - }, - testCombinedDts: { - src: [ - path.join(localCfg.outTnsCoreModules, 'tns-core-modules.d.ts'), - ], - outDir: localCfg.outDir, - dest: localCfg.outDir, - options: Object.assign({}, tsOptions, { noLib: false }) - } - }, tslint: { build: { files: { @@ -400,6 +347,10 @@ module.exports = function(grunt) { callback: assignGitSHA } }, + compileAll: "npm run compile-all", + compileNodeTests: "npm run compile-node-tests", + compileCheckBaseDts: "npm run compile-check-base-dts", + compileCheckCombinedDts: "npm run compile-check-combined-dts", }, simplemocha: { node: { @@ -431,7 +382,6 @@ module.exports = function(grunt) { grunt.loadNpmTasks("grunt-contrib-clean"); grunt.loadNpmTasks("grunt-contrib-copy"); - grunt.loadNpmTasks("grunt-ts"); grunt.loadNpmTasks("grunt-tslint"); grunt.loadNpmTasks("grunt-exec"); grunt.loadNpmTasks("grunt-shell"); @@ -446,8 +396,8 @@ module.exports = function(grunt) { ]); grunt.registerTask("compile-ts", [ - "ts:buildDts", - "ts:build", + "shell:compileCheckBaseDts", + "shell:compileAll", "clean:typeScriptLeftovers", "copy:childPackageFiles" ]); @@ -508,12 +458,12 @@ module.exports = function(grunt) { "copy:definitionFiles", "copy:jsLibs", "generate-tns-core-modules-dts", - "ts:testCombinedDts", + "shell:compileCheckCombinedDts", ]); grunt.registerTask("node-tests", [ "clean:nodeTests", - "ts:buildNodeTests", + "shell:compileNodeTests", "copy:childPackageFiles", "copy:jsLibs", "env:nodeTests", diff --git a/node-tests/test-angular-xml.ts b/node-tests/test-angular-xml.ts index f39887e0a..1ab65689d 100644 --- a/node-tests/test-angular-xml.ts +++ b/node-tests/test-angular-xml.ts @@ -1,6 +1,6 @@ import {assert} from "chai"; -import * as xmlModule from "xml"; -var xml: typeof xmlModule = require("../tns-core-modules/xml"); +//TODO: use a path mapping to the "xml" module after upgrading to TS 2.1 +var xml = require("../tns-core-modules/xml"); describe("angular xml parser", () => { let last_element = null; @@ -8,7 +8,7 @@ describe("angular xml parser", () => { let parser = null; beforeEach(() => { - parser = new xml.XmlParser(function (event: xmlModule.ParserEvent) { + parser = new xml.XmlParser(function (event) { switch (event.eventType) { case xml.ParserEventType.StartElement: last_element = event.elementName; diff --git a/node-tests/test-xml.ts b/node-tests/test-xml.ts index 009c20689..3f3f1de3e 100644 --- a/node-tests/test-xml.ts +++ b/node-tests/test-xml.ts @@ -1,6 +1,6 @@ import {assert} from "chai"; -import * as xmlModule from "xml"; -var xml: typeof xmlModule = require("../tns-core-modules/xml"); +//TODO: use a path mapping to the "xml" module after upgrading to TS 2.1 +var xml = require("../tns-core-modules/xml"); describe("xml parser", () => { let last_element = null; @@ -9,7 +9,7 @@ describe("xml parser", () => { let parser = null; beforeEach(() => { - parser = new xml.XmlParser(function (event: xmlModule.ParserEvent) { + parser = new xml.XmlParser(function (event) { switch (event.eventType) { case xml.ParserEventType.StartElement: last_element = event.elementName; diff --git a/package.json b/package.json index 94eedda69..78b22f1c5 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,10 @@ "scripts": { "setup": "npm run dev-link-tns-platform-declarations && npm run dev-link-tns-core-modules && npm run dev-link-tests && npm run dev-link-apps", "tsc": "tsc", + "compile-all": "tsc -p tsconfig.json --outDir bin/dist", + "compile-check-base-dts": "tsc -p tsconfig.base-dts.json", + "compile-node-tests": "tsc -p tsconfig.node-tests.json --outDir bin/dist/node-tests", + "compile-check-combined-dts": "tsc -p tsconfig.combined-dts.json", "tsc-w": "tsc --skipLibCheck -w", "dev-tsc-tns-platform-declarations": "tsc -p tns-platform-declarations", "dev-tsc-tests": "tsc -p tests", diff --git a/tsconfig.base-dts.json b/tsconfig.base-dts.json new file mode 100644 index 000000000..f53dde4d7 --- /dev/null +++ b/tsconfig.base-dts.json @@ -0,0 +1,45 @@ +{ + "compilerOptions": { + "noEmit": true, + "noEmitOnError": true, + "noEmitHelpers": true, + "target": "es5", + "module": "commonjs", + "declaration": false, + "noImplicitAny": false, + "noImplicitUseStrict": true, + "experimentalDecorators": true, + "sourceMap": true, + "jsx": "react", + "reactNamespace": "UIBuilder", + "lib": [ + "es2016" + ] + }, + "include": [ + "tns-core-modules/**/*.d.ts" + ], + "exclude": [ + "tns-platform-declarations/node_modules/", + "tns-platform-declarations/package/", + "tns-core-modules/node_modules/", + "tns-core-modules/package/", + "tests/node_modules", + "tests/package/", + "tests/platforms", + "apps/node_modules", + "apps/package/", + "apps/platforms", + "node_modules/", + "package/", + "bin", + "build", + "Deploy", + "out", + "obj", + "tns-platform-declarations/references.d.ts", + "tns-core-modules/references.d.ts", + "tns-platform-declarations/ios/objc-x86_64/", + "tns-platform-declarations/android/" + ] +} diff --git a/tsconfig.combined-dts.json b/tsconfig.combined-dts.json new file mode 100644 index 000000000..6d893f0ab --- /dev/null +++ b/tsconfig.combined-dts.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "noEmit": true, + "noEmitOnError": true, + "noEmitHelpers": true, + "target": "es5", + "module": "commonjs", + "declaration": false, + "noImplicitAny": false, + "noImplicitUseStrict": true, + "experimentalDecorators": true, + "sourceMap": true, + "jsx": "react", + "reactNamespace": "UIBuilder" + }, + "include": [ + "bin/dist/tns-core-modules/tns-core-modules.d.ts" + ] +} diff --git a/tsconfig.json b/tsconfig.json index 675ff87ba..0e082028e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,6 +7,7 @@ "declaration": false, "noImplicitAny": false, "noImplicitUseStrict": true, + "removeComments": true, "experimentalDecorators": true, "diagnostics": true, "sourceMap": true, diff --git a/tsconfig.node-tests.json b/tsconfig.node-tests.json new file mode 100644 index 000000000..a042423cd --- /dev/null +++ b/tsconfig.node-tests.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "noEmitOnError": true, + "noEmitHelpers": true, + "target": "es5", + "module": "commonjs", + "declaration": false, + "noImplicitAny": false, + "noImplicitUseStrict": true, + "experimentalDecorators": true, + "sourceMap": true, + "jsx": "react", + "reactNamespace": "UIBuilder", + "lib": [ + "es2016" + ] + }, + "include": [ + "tns-core-modules/js-libs/easysax/**/*.ts", + "tns-core-modules/module.d.ts", + "tns-core-modules/lib.core.d.ts", + "tns-core-modules/lib.dom.d.ts", + "tns-core-modules/es-collections.d.ts", + "tns-core-modules/declarations.d.ts", + "tns-core-modules/es6-promise.d.ts", + "node-tests/**/*.ts" + ] +}