Skip to content
This repository has been archived by the owner on Jul 30, 2018. It is now read-only.

Commit

Permalink
Migration to TS2.0 (#6)
Browse files Browse the repository at this point in the history
* Change matching logic to ensure no null tokens
* configure travis to use node version 6+
* use latest 'include' config and git ignore the temp 'tsconfig' files
* add 'noImplicitThis' to tsconfig
* migrate for 'strictNullChecks'
* Configure for TS2.0

Fixes #5
Merges #6
  • Loading branch information
agubler authored and kitsonk committed Aug 5, 2016
1 parent 8ba42d1 commit 698655c
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
/typings
.baseDir.ts
.tscache
.tsconfig*.json
coverage-unmapped.json
npm-debug.log
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sudo: false
language: node_js
node_js:
- '5.1'
- '6'
env:
global:
- SAUCE_USERNAME: dojo2-ts-ci
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@
"remap-istanbul": "^0.6.4",
"sinon": "^1.17.4",
"tslint": "^3.11.0",
"typescript": "^1.8.10"
"typescript": "beta"
}
}
12 changes: 6 additions & 6 deletions src/has.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Require, Config } from './loader';
/**
* The valid return types from a feature test
*/
export type FeatureTestResult = boolean | string | number;
export type FeatureTestResult = boolean | string | number | undefined;

/**
* A function that tests for a feature and returns a result
Expand Down Expand Up @@ -43,11 +43,11 @@ export function load(resourceId: string, require: Require, load: (value?: any) =
* @param resourceId The id of the module
* @param normalize Resolves a relative module id into an absolute module id
*/
export function normalize(resourceId: string, normalize: (moduleId: string) => string): string {
const tokens = resourceId.match(/[\?:]|[^:\?]*/g);
export function normalize(resourceId: string, normalize: (moduleId: string) => string): string | null {
const tokens: RegExpMatchArray = resourceId.match(/[\?:]|[^:\?]*/g) || [];
let i = 0;

function get(skip?: boolean): string {
function get(skip?: boolean): string | null {
const term = tokens[i++];
if (term === ':') {
// empty string module name, resolves to null
Expand All @@ -71,9 +71,9 @@ export function normalize(resourceId: string, normalize: (moduleId: string) => s
}
}

resourceId = get();
const id = get();

return resourceId && normalize(resourceId);
return id && normalize(id);
}

/**
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/intern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const maxConcurrency = 2;
export const tunnel = 'BrowserStackTunnel';

// Support running unit tests from a web server that isn't the intern proxy
export const initialBaseUrl: string = (function () {
export const initialBaseUrl: string | null = (function () {
if (typeof location !== 'undefined' && location.pathname.indexOf('__intern/') > -1) {
return '/';
}
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/has.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ registerSuite({

'null test should not throw'() {
assert.doesNotThrow(function () {
hasAdd('baz', null);
hasAdd('baz', <any> null);
}, TypeError);
},

Expand Down Expand Up @@ -164,7 +164,7 @@ registerSuite({
},

'null test value counts as being defined'() {
hasAdd(feature, null);
hasAdd(feature, <any> null);
assert.isTrue(hasExists(feature));
}
},
Expand Down Expand Up @@ -251,7 +251,7 @@ registerSuite({
const requireSpy = sinon.spy(require);
const loadedStub = sinon.stub();

hasLoad(null, require, loadedStub);
hasLoad(<any> null, require, loadedStub);
assert.isTrue(loadedStub.calledOnce);
assert.isFalse(requireSpy.calledOnce);
}
Expand Down
23 changes: 5 additions & 18 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.8.10",
"version": "2.0.0",
"compilerOptions": {
"declaration": false,
"module": "umd",
Expand All @@ -8,26 +8,13 @@
"removeComments": false,
"sourceMap": true,
"target": "es5",
"moduleResolution": "classic"
"moduleResolution": "classic",
"strictNullChecks": true,
"noImplicitThis": true
},
"filesGlob": [
"include": [
"./typings/index.d.ts",
"./src/**/*.ts",
"./tests/**/*.ts"
],
"files": [
"./typings/index.d.ts",
"./src/has.ts",
"./src/loader.d.ts",
"./src/main.ts",
"./tests/functional/all.ts",
"./tests/intern-local.ts",
"./tests/intern-saucelabs.ts",
"./tests/intern.ts",
"./tests/support/Reporter.ts",
"./tests/support/util.ts",
"./tests/unit/all.ts",
"./tests/unit/has.ts",
"./tests/unit/main.ts"
]
}

0 comments on commit 698655c

Please sign in to comment.