Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit 5297ecc

Browse files
committed
Update: Open up TS peerDependency, warn when using non-supported version (fixes #167)
1 parent 0fadfc3 commit 5297ecc

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ A parser that converts TypeScript into an [ESTree](https://github.com/estree/est
66

77
## Supported TypeScript Version
88

9-
The version of TypeScript supported by this parser is `~2.2.1`. This is reflected in the `peerDependency` requirement within the package.json file.
9+
We will always endeavor to support the latest stable version of TypeScript.
1010

11-
**Please ensure that you are using this version before submitting any issues.**
11+
The version of TypeScript currently supported by this parser is `~2.2.1`. This is reflected in the `devDependency` requirement within the package.json file, and it is what the tests will be run against. We have an open `peerDependency` requirement in order to allow for experimentation on newer/beta versions of TypeScript.
12+
13+
If you use a non-supported version of TypeScript, the parser will log a warning to the console.
14+
15+
**Please ensure that you are using a supported version before submitting any issues/bug reports.**
1216

1317
## Usage
1418

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@
5252
},
5353
"dependencies": {
5454
"lodash.unescape": "4.0.0",
55-
"object-assign": "^4.0.1"
55+
"object-assign": "^4.0.1",
56+
"semver": "^4.3.6"
5657
},
5758
"peerDependencies": {
58-
"typescript": "~2.2.1"
59+
"typescript": "*"
5960
}
6061
}

parser.js

+21-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,27 @@
99
"use strict";
1010

1111
var astNodeTypes = require("./lib/ast-node-types"),
12-
ts = require("typescript");
12+
ts = require("typescript"),
13+
semver = require("semver");
14+
15+
var SUPPORTED_TYPESCRIPT_VERSIONS = require("./package.json").devDependencies.typescript;
16+
var ACTIVE_TYPESCRIPT_VERSION = ts.version;
17+
18+
var isRunningSupportedTypeScriptVersion = semver.satisfies(ACTIVE_TYPESCRIPT_VERSION, SUPPORTED_TYPESCRIPT_VERSIONS);
19+
20+
if (!isRunningSupportedTypeScriptVersion) {
21+
var border = "=============";
22+
var versionWarning = [
23+
border,
24+
"WARNING: You are currently running a version of TypeScript which is not officially supported by typescript-eslint-parser.",
25+
"You may find that it works just fine, or you may not.",
26+
"SUPPORTED TYPESCRIPT VERSIONS: " + SUPPORTED_TYPESCRIPT_VERSIONS,
27+
"YOUR TYPESCRIPT VERSION: " + ACTIVE_TYPESCRIPT_VERSION,
28+
"Please only submit bug reports when using the officially supported version.",
29+
border
30+
];
31+
console.warn(versionWarning.join("\n\n"));
32+
}
1333

1434
var extra;
1535

0 commit comments

Comments
 (0)