Skip to content

Commit b45cbe9

Browse files
committed
No more ambient modules for tns-core-modules/* subpackages.
- Use path mappings in tsconfig.json to resolve module typings - Only use ambient mobules for global API's - Move single-file modules to a subdir with the same name so that we can provide a hand-written typing next to it (via package.json) - Delete all mentions of tns-core-modules.d.ts - Delete reference d.ts assembly build steps. Not needed anymore. - HACK! Use a <reference> for global typings in application.d.ts to avoid publishing a separate @types/tns-core-modules package. - Rename declarations.d.ts to tns-core-modules.d.ts to preserve JS project mappings in references.d.ts (the only place we use those)
1 parent 1af8c6c commit b45cbe9

File tree

230 files changed

+9260
-10118
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

230 files changed

+9260
-10118
lines changed

apps/references.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/// <reference path="../tns-platform-declarations/android.d.ts" />
22
/// <reference path="../tns-platform-declarations/ios.d.ts" />
33

4-
/// <reference path="../tns-core-modules/tns-core-modules.d.ts" />
54
/// <reference path="../tns-core-modules/ui/styling/css-selector-parser.d.ts" />

apps/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
"node_modules",
55
"platforms"
66
]
7-
}
7+
}

gruntfile.js

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -78,33 +78,6 @@ module.exports = function(grunt) {
7878
return localCfg.mainPackageContent.version + "-" + buildVersion;
7979
};
8080

81-
var writeDtsFile = function writeDtsFile(dtsFiles, outDir, outFile) {
82-
var dtsLines = dtsFiles.map(function(dtsFile) {
83-
return '/// <reference path="' + dtsFile + '" />';
84-
});
85-
var combinedDtsPath = path.join(outDir, outFile);
86-
grunt.file.write(combinedDtsPath, dtsLines.join('\n'));
87-
};
88-
89-
var generateModulesDts = function generateModulesDts(outDir, srcDir) {
90-
var dtsFiles = grunt.file.expand({cwd: srcDir }, [
91-
"**/*.d.ts",
92-
//Exclude the d.ts files in the apps folder - these are part of the apps and are already packed there!
93-
"!docs-shims.d.ts",
94-
"!node-tests/**",
95-
"!org.nativescript.widgets.d.ts",
96-
"!android17.d.ts",
97-
"!**/*.android.d.ts",
98-
"!ios/**",
99-
"!**/*.ios.d.ts",
100-
"!tns-core-modules.d.ts",
101-
"!references.d.ts",
102-
].concat(localCfg.defaultExcludes));
103-
dtsFiles.sort();
104-
105-
writeDtsFile(dtsFiles, outDir, "tns-core-modules/tns-core-modules.d.ts");
106-
};
107-
10881
// Configure localCfg
10982
var outDir = "./bin/dist";
11083
var srcDir = ".";
@@ -300,9 +273,8 @@ module.exports = function(grunt) {
300273
}
301274
},
302275
compileAll: "npm run compile-all",
276+
setupLinks: "npm run setup",
303277
compileNodeTests: "npm run compile-node-tests",
304-
compileCheckBaseDts: "npm run compile-check-base-dts",
305-
compileCheckCombinedDts: "npm run compile-check-combined-dts",
306278
tslint: "npm run tslint",
307279
},
308280
simplemocha: {
@@ -348,7 +320,7 @@ module.exports = function(grunt) {
348320
]);
349321

350322
grunt.registerTask("compile-ts", [
351-
"shell:compileCheckBaseDts",
323+
"shell:setupLinks",
352324
"shell:compileAll",
353325
"clean:typeScriptLeftovers",
354326
"copy:childPackageFiles"
@@ -388,10 +360,6 @@ module.exports = function(grunt) {
388360
});
389361
});
390362

391-
grunt.registerTask("generate-tns-core-modules-dev-dts", generateModulesDts.bind(null, ".", localCfg.srcTnsCoreModules));
392-
393-
grunt.registerTask("generate-tns-core-modules-dts", generateModulesDts.bind(null, localCfg.outDir, localCfg.outTnsCoreModules));
394-
395363
//aliasing pack-modules for backwards compatibility
396364
grunt.registerTask("pack-modules", [
397365
"compile-modules",
@@ -409,8 +377,6 @@ module.exports = function(grunt) {
409377
"collect-modules-raw-files",
410378
"copy:definitionFiles",
411379
"copy:jsLibs",
412-
"generate-tns-core-modules-dts",
413-
"shell:compileCheckCombinedDts",
414380
]);
415381

416382
grunt.registerTask("node-tests", [

tests/app/http-string-worker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
require("globals");
2-
import http = require("http");
2+
import * as http from "tns-core-modules/http";
33

44
declare var postMessage : any;
55

66
http.getString("https://httpbin.org/get").then(function (r) {
77
postMessage(r);
88
}, function (e) {
99
throw e;
10-
});
10+
});

tests/app/http-tests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* tslint:disable:no-unused-variable */
22
import * as TKUnit from "./TKUnit";
3-
import * as http from "http";
3+
import * as http from "tns-core-modules/http";
44
import * as types from "utils/types";
55
import * as fs from "file-system";
66
import { addHeader } from "http/http-request";
@@ -650,4 +650,4 @@ export var test_getString_WorksProperlyInWorker = function () {
650650
}
651651

652652
TKUnit.waitUntilReady(() => ready);
653-
}
653+
}

tests/app/navigation/transition-tests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import * as helper from "../ui/helper";
33
import * as platform from "platform";
44
import * as trace from "trace";
55
import { Color } from "color";
6-
import { NavigationEntry, NavigationTransition, topmost as topmostFrame, traceEnabled } from "ui/frame";
6+
import { NavigationEntry, NavigationTransition, topmost as topmostFrame } from "ui/frame";
77
import { Page } from "ui/page";
88
import { AnimationCurve } from "ui/enums"
99

1010
function _testTransition(navigationTransition: NavigationTransition) {
1111
var testId = `Transition[${JSON.stringify(navigationTransition)}]`;
12-
if (traceEnabled()) {
12+
if (trace.isEnabled()) {
1313
trace.write(`Testing ${testId}`, trace.categories.Test);
1414
}
1515
var navigationEntry: NavigationEntry = {

tests/app/pages/page8.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as stacks from "ui/layouts/stack-layout";
44
import * as scroll from "ui/scroll-view";
55
import * as textView from "ui/text-view";
66
import * as timer from "timer";
7-
import * as http from "http";
7+
import * as http from "tns-core-modules/http";
88
import * as trace from "trace";
99
trace.enable();
1010
trace.setCategories(trace.categories.Style);
@@ -63,4 +63,4 @@ export function createPage() {
6363
return page;
6464
}
6565

66-
//export var Page = page;
66+
//export var Page = page;

tests/app/xml-declaration/mainPage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as observable from "data/observable";
22
import * as view from "ui/core/view";
33
import * as label from "ui/label";
44
import * as pages from "ui/page";
5-
import * as http from "http";
5+
import * as http from "tns-core-modules/http";
66

77
var obj = new observable.Observable();
88
obj.set("id", 0);
@@ -53,4 +53,4 @@ export function MyPageLoaded(args: observable.EventData) {
5353

5454
export function setPicture(args: observable.EventData) {
5555
//
56-
}
56+
}

tests/references.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/// <reference path="../tns-platform-declarations/android.d.ts" />
22
/// <reference path="../tns-platform-declarations/ios.d.ts" />
33

4-
/// <reference path="../tns-core-modules/tns-core-modules.d.ts" />
54
/// <reference path="../tns-core-modules/ui/styling/css-selector-parser.d.ts" />
Lines changed: 58 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,61 @@
11
/**
22
* Allows you to save and restore any kind of information related to your application.
33
*/
4-
declare module "application-settings" {
5-
/**
6-
* Checks whether such a key exists.
7-
* @param key The key to check for.
8-
*/
9-
export function hasKey(key: string): boolean;
10-
11-
/**
12-
* Gets a value (if existing) for a key as a Boolean Object. A default value can be provided in case there is no existing value.
13-
* @param key The key to check for.
14-
* @param defaultValue An optional value to be returned in case there is no existing value.
15-
*/
16-
export function getBoolean(key: string, defaultValue?: boolean): boolean;
17-
18-
/**
19-
* Gets a value (if existing) for a key as a String Object. A default value can be provided in case there is no existing value.
20-
* @param key The key to check for.
21-
* @param defaultValue An optional value to be returned in case there is no existing value.
22-
*/
23-
export function getString(key: string, defaultValue?: string): string;
24-
25-
/**
26-
* Gets a value (if existing) for a key as a Number Object. A default value can be provided in case there is no existing value.
27-
* @param key The key to check for.
28-
* @param defaultValue An optional value to be returned in case there is no existing value.
29-
*/
30-
export function getNumber(key: string, defaultValue?: number): number;
31-
32-
/**
33-
* Sets a Boolean Object for a key.
34-
* @param key The key.
35-
* @param value The value.
36-
*/
37-
export function setBoolean(key: string, value: boolean): void;
38-
39-
/**
40-
* Sets a String Object for a key.
41-
* @param key The key.
42-
* @param value The value.
43-
*/
44-
export function setString(key: string, value: string): void;
45-
46-
/**
47-
* Sets a Number Object for a key.
48-
* @param key The key.
49-
* @param value The value.
50-
*/
51-
export function setNumber(key: string, value: number): void;
52-
53-
/**
54-
* Removes a value (if existing) for a key.
55-
* @param key The key to check for.
56-
*/
57-
export function remove(key: string): void;
58-
59-
/**
60-
* Removes all values.
61-
*/
62-
export function clear(): void;
63-
}
4+
/**
5+
* Checks whether such a key exists.
6+
* @param key The key to check for.
7+
*/
8+
export function hasKey(key: string): boolean;
9+
10+
/**
11+
* Gets a value (if existing) for a key as a Boolean Object. A default value can be provided in case there is no existing value.
12+
* @param key The key to check for.
13+
* @param defaultValue An optional value to be returned in case there is no existing value.
14+
*/
15+
export function getBoolean(key: string, defaultValue?: boolean): boolean;
16+
17+
/**
18+
* Gets a value (if existing) for a key as a String Object. A default value can be provided in case there is no existing value.
19+
* @param key The key to check for.
20+
* @param defaultValue An optional value to be returned in case there is no existing value.
21+
*/
22+
export function getString(key: string, defaultValue?: string): string;
23+
24+
/**
25+
* Gets a value (if existing) for a key as a Number Object. A default value can be provided in case there is no existing value.
26+
* @param key The key to check for.
27+
* @param defaultValue An optional value to be returned in case there is no existing value.
28+
*/
29+
export function getNumber(key: string, defaultValue?: number): number;
30+
31+
/**
32+
* Sets a Boolean Object for a key.
33+
* @param key The key.
34+
* @param value The value.
35+
*/
36+
export function setBoolean(key: string, value: boolean): void;
37+
38+
/**
39+
* Sets a String Object for a key.
40+
* @param key The key.
41+
* @param value The value.
42+
*/
43+
export function setString(key: string, value: string): void;
44+
45+
/**
46+
* Sets a Number Object for a key.
47+
* @param key The key.
48+
* @param value The value.
49+
*/
50+
export function setNumber(key: string, value: number): void;
51+
52+
/**
53+
* Removes a value (if existing) for a key.
54+
* @param key The key to check for.
55+
*/
56+
export function remove(key: string): void;
57+
58+
/**
59+
* Removes all values.
60+
*/
61+
export function clear(): void;

0 commit comments

Comments
 (0)