Skip to content
This repository was archived by the owner on Jun 27, 2018. It is now read-only.

Commit 9efa9ab

Browse files
authored
build: support TypeScript 2.9 RC (#105)
* ci: run with typescript@rc * test: fix sourcemap result for microsoft/TypeScript#21777
1 parent ded0fa8 commit 9efa9ab

File tree

6 files changed

+104
-14
lines changed

6 files changed

+104
-14
lines changed

.circleci/config.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,15 @@ jobs:
5959
npm install --no-save [email protected]
6060
npm test
6161
- run:
62-
name: Test with TypeScript 2.7
62+
name: Test with TypeScript 2.8
6363
command: |
6464
npm install --no-save typescript@latest
6565
npm test
66+
- run:
67+
name: Test with TypeScript 2.9 RC
68+
command: |
69+
npm install --no-save typescript@rc
70+
npm test
6671
- save_cache:
6772
key: v{{ .Environment.CIRCLE_CACHE_VERSION }}-npm-lock-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package-lock.json" }}
6873
paths:

appveyor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ test_script:
3939
- npm test
4040
- npm install --no-save typescript@latest
4141
- npm test
42+
- npm install --no-save typescript@rc
43+
- npm test
4244

4345
# Don't actually build.
4446
build: off

index.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ declare namespace tss {
2020
* @throw {Error} A syntactic error or a semantic error (if doSemanticChecks is true)
2121
*/
2222
compile(code: string, fileName?: string): string;
23-
private createService();
24-
private getTypeScriptBinDir();
25-
private getDefaultLibFileName(options);
26-
private toJavaScript(service, fileName);
27-
private formatDiagnostics(diagnostics);
23+
private createService;
24+
private getTypeScriptBinDir;
25+
private getDefaultLibFileName;
26+
private toJavaScript;
27+
private formatDiagnostics;
2828
}
2929
}
3030
export = tss;

package-lock.json

Lines changed: 67 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
"test": "npm run prepare && mocha"
1414
},
1515
"dependencies": {
16-
"typescript": "^2.2.1"
16+
"typescript": "^2.2.1 || ^2.9.0-rc"
1717
},
1818
"devDependencies": {
1919
"@types/node": "^6.0.111",
20-
"mocha": "^5.2.0"
20+
"mocha": "^5.2.0",
21+
"pkg-up": "^2.0.0",
22+
"semver": "^5.5.0"
2123
},
2224
"homepage": "https://github.com/teppeis/typescript-simple",
2325
"repository": {

test/test.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ var assert = require('assert');
22
var fs = require('fs');
33
var path = require('path');
44
var eol = require('os').EOL;
5-
5+
var semver = require('semver');
6+
var pkgUp = require('pkg-up');
67
var ts = require('typescript');
78
var tss = require('../');
89
var TypeScriptSimple = tss.TypeScriptSimple;
@@ -242,13 +243,24 @@ describe('typescript-simple', function() {
242243
var tss = new TypeScriptSimple({jsx: ts.JsxEmit.Preserve, sourceMap: true});
243244
var src = 'var foo: any = <bar />;';
244245
var srcFile = 'foo/test.tsx';
245-
var sourceMap = '{"version":3,"file":"test.jsx","sourceRoot":"","sources":["test.tsx"],"names":[],"mappings":"AAAA,IAAI,GAAG,GAAQ,CAAC,GAAG,GAAG,CAAC"}';
246+
var sourceMap = {
247+
"version": 3,
248+
"file": "test.jsx",
249+
"sourceRoot": "",
250+
"sources": ["test.tsx"],
251+
"names": [],
252+
};
253+
if (isTSVerGte('2.9.0-rc')) {
254+
sourceMap.mappings = "AAAA,IAAI,GAAG,GAAQ,CAAC,GAAG,CAAC,AAAD,EAAG,CAAC";
255+
} else {
256+
sourceMap.mappings = "AAAA,IAAI,GAAG,GAAQ,CAAC,GAAG,GAAG,CAAC";
257+
}
246258
var expectedPrefix = 'var foo = <bar />;' + eol + '//# sourceMappingURL=data:application/json;base64,';
247259
var actual = tss.compile(src, srcFile);
248260
var match = /(^[\s\S]*;base64,)(.*)$/.exec(actual);
249261
assert(match);
250262
assert.equal(match[1], expectedPrefix);
251-
assert.deepEqual(JSON.parse(Buffer.from(match[2], 'base64').toString()), JSON.parse(sourceMap));
263+
assert.deepEqual(JSON.parse(Buffer.from(match[2], 'base64').toString()), sourceMap);
252264
});
253265
});
254266

@@ -281,3 +293,8 @@ describe('typescript-simple', function() {
281293
assert.equal(tss.compile(src), expected);
282294
});
283295
});
296+
297+
function isTSVerGte(ver) {
298+
var pkg = require(pkgUp.sync(path.dirname(require.resolve('typescript'))));
299+
return semver.gte(pkg.version, ver);
300+
}

0 commit comments

Comments
 (0)