Skip to content

Commit d58488b

Browse files
authored
Create tsconfig.json for old TypeScript versions (#723)
1 parent 5ee273e commit d58488b

File tree

5 files changed

+23
-12
lines changed

5 files changed

+23
-12
lines changed

package-lock.json

Lines changed: 3 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"semver": "^5.1.0",
7070
"tslint": "^5.11.0",
7171
"tslint-config-standard": "^8.0.1",
72-
"typescript": "^3.1.1"
72+
"typescript": "^3.1.5"
7373
},
7474
"peerDependencies": {
7575
"typescript": ">=2.0"

src/index.spec.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import ts = require('typescript')
66
import proxyquire = require('proxyquire')
77
import { register, VERSION } from './index'
88

9-
const testDir = join(__dirname, '../tests')
9+
const TEST_DIR = join(__dirname, '../tests')
1010
const EXEC_PATH = join(__dirname, '../dist/bin')
11-
const BIN_EXEC = `node "${EXEC_PATH}" --project "${testDir}/tsconfig.json"`
11+
const PROJECT = join(TEST_DIR, semver.gte(ts.version, '2.5.0') ? 'tsconfig.json5' : 'tsconfig.json')
12+
const BIN_EXEC = `node "${EXEC_PATH}" --project "${PROJECT}"`
1213

1314
const SOURCE_MAP_REGEXP = /\/\/# sourceMappingURL=data:application\/json;charset=utf\-8;base64,[\w\+]+=*$/
1415

@@ -33,7 +34,7 @@ describe('ts-node', function () {
3334

3435
it('should register via cli', function (done) {
3536
exec(`node -r ../register hello-world.ts`, {
36-
cwd: testDir
37+
cwd: TEST_DIR
3738
}, function (err, stdout) {
3839
expect(err).to.equal(null)
3940
expect(stdout).to.equal('Hello, world!\n')
@@ -43,7 +44,7 @@ describe('ts-node', function () {
4344
})
4445

4546
it('should execute cli with absolute path', function (done) {
46-
exec(`${BIN_EXEC} "${join(testDir, 'hello-world')}"`, function (err, stdout) {
47+
exec(`${BIN_EXEC} "${join(TEST_DIR, 'hello-world')}"`, function (err, stdout) {
4748
expect(err).to.equal(null)
4849
expect(stdout).to.equal('Hello, world!\n')
4950

@@ -263,7 +264,7 @@ describe('ts-node', function () {
263264

264265
describe('register', function () {
265266
register({
266-
project: join(testDir, 'tsconfig.json'),
267+
project: PROJECT,
267268
compilerOptions: {
268269
jsx: 'preserve'
269270
}

tests/tsconfig.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
"compilerOptions": {
33
"jsx": "react",
44
"noEmit": true,
5-
// Global type definitions.
65
"typeRoots": [
76
"./typings",
8-
"../node_modules/@types",
9-
],
7+
"../node_modules/@types"
8+
]
109
}
1110
}

tests/tsconfig.json5

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"compilerOptions": {
3+
"jsx": "react",
4+
"noEmit": true,
5+
// Global type definitions.
6+
"typeRoots": [
7+
"./typings",
8+
"../node_modules/@types",
9+
],
10+
}
11+
}

0 commit comments

Comments
 (0)