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

Update: Open TS peerDependency, warn non-supported version (fixes #167) #193

Merged
merged 1 commit into from
Apr 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ A parser that converts TypeScript into an [ESTree](https://github.com/estree/est

## Supported TypeScript Version

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

**Please ensure that you are using this version before submitting any issues.**
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.

If you use a non-supported version of TypeScript, the parser will log a warning to the console.

**Please ensure that you are using a supported version before submitting any issues/bug reports.**

## Usage

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@
},
"dependencies": {
"lodash.unescape": "4.0.0",
"object-assign": "^4.0.1"
"object-assign": "^4.0.1",
"semver": "^4.3.6"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any particular reason this is not using 5?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't think of one. I looked at the commit log and seems they only dropped support for AMD modules and minifying the code in v5. Do you want to create a PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

Interesting message on running npm install here, btw.

npm WARN The package semver is included as both a dev and production dependency.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need it in devDependencies anymore as it is used during runtime.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

},
"peerDependencies": {
"typescript": "~2.2.1"
"typescript": "*"
}
}
22 changes: 21 additions & 1 deletion parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,27 @@
"use strict";

var astNodeTypes = require("./lib/ast-node-types"),
ts = require("typescript");
ts = require("typescript"),
semver = require("semver");

var SUPPORTED_TYPESCRIPT_VERSIONS = require("./package.json").devDependencies.typescript;
var ACTIVE_TYPESCRIPT_VERSION = ts.version;

var isRunningSupportedTypeScriptVersion = semver.satisfies(ACTIVE_TYPESCRIPT_VERSION, SUPPORTED_TYPESCRIPT_VERSIONS);

if (!isRunningSupportedTypeScriptVersion) {
var border = "=============";
var versionWarning = [
border,
"WARNING: You are currently running a version of TypeScript which is not officially supported by typescript-eslint-parser.",
"You may find that it works just fine, or you may not.",
"SUPPORTED TYPESCRIPT VERSIONS: " + SUPPORTED_TYPESCRIPT_VERSIONS,
"YOUR TYPESCRIPT VERSION: " + ACTIVE_TYPESCRIPT_VERSION,
"Please only submit bug reports when using the officially supported version.",
border
];
console.warn(versionWarning.join("\n\n"));
}

var extra;

Expand Down