Permalink
Browse files

feat(*): change TypeScript version range to >=3.2.1 <3.4.0 (#184)

  • Loading branch information...
JamesHenry committed Feb 4, 2019
1 parent e37a1ed commit f513a143f549f8ccc8ec4851f245364c4542af73
@@ -42,11 +42,13 @@ The `canary` (latest master) version is:
## Supported TypeScript Version
We will always endeavor to support the latest stable version of TypeScript.
We will always endeavor to support the latest stable version of TypeScript. Sometimes, but not always, changes in TypeScript will not require breaking changes in this project, and so we are able to support more than one version of TypeScript.
The version of TypeScript currently supported by this parser is `~3.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.
**The version range of TypeScript currently supported by this parser is `>=3.2.1 <3.4.0`.**
If you use a non-supported version of TypeScript, the parser will log a warning to the console.
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. If you want to disable this warning, you can configure this in your `parserOptions`. See: [`@typescript-eslint/parser`](./packages/parser/) and [`@typescript-eslint/typescript-estree`](./packages/typescript-estree/).
**Please ensure that you are using a supported version before submitting any issues/bug reports.**
@@ -69,6 +69,6 @@
"rimraf": "^2.6.3",
"ts-jest": "^23.10.4",
"tslint": "^5.11.0",
"typescript": "~3.2.1"
"typescript": ">=3.2.1 <3.4.0"
}
}
@@ -34,6 +34,6 @@
},
"peerDependencies": {
"eslint": "^5.0.0",
"typescript": "~3.2.1"
"typescript": "*"
}
}
@@ -54,6 +54,8 @@ The following additional configuration options are available by specifying them

- **`extraFileExtensions`** - default `undefined`. This option allows you to provide one or more additional file extensions which should be considered in the TypeScript Program compilation. E.g. a `.vue` file

- **`warnOnUnsupportedTypeScriptVersion`** - default `true`. This option allows you to toggle the warning that the parser will give you if you use a version of TypeScript which is not explicitly supported

### .eslintrc.json

```json
@@ -17,4 +17,5 @@ export interface ParserOptions {
errorOnTypeScriptSyntacticAndSemanticIssues?: boolean;
tsconfigRootDir?: string;
extraFileExtensions?: string[];
warnOnUnsupportedTypeScriptVersion?: boolean;
}
@@ -75,6 +75,18 @@ export function parseForESLint(
}
}

/**
* Allow the user to suppress the warning from typescript-estree if they are using an unsupported
* version of TypeScript
*/
const warnOnUnsupportedTypeScriptVersion = validateBoolean(
options.warnOnUnsupportedTypeScriptVersion,
true
);
if (!warnOnUnsupportedTypeScriptVersion) {
parserOptions.loggerFn = false;
}

const { ast, services } = parseAndGenerateServices(code, parserOptions);
ast.sourceType = options.sourceType;

@@ -84,4 +84,25 @@ describe('parser', () => {
`"Cannot assign to read only property 'ArrayExpression' of object '#<Object>'"`
);
});

it('`warnOnUnsupportedTypeScriptVersion: false` should set `loggerFn: false` on typescript-estree', () => {
const code = 'const valid = true;';
const spy = jest.spyOn(typescriptESTree, 'parseAndGenerateServices');
parseForESLint(code, { warnOnUnsupportedTypeScriptVersion: true });
expect(spy).toHaveBeenCalledWith(code, {
ecmaFeatures: {},
jsx: false,
sourceType: 'script',
useJSXTextNode: true
});
parseForESLint(code, { warnOnUnsupportedTypeScriptVersion: false });
expect(spy).toHaveBeenCalledWith(code, {
ecmaFeatures: {},
jsx: false,
sourceType: 'script',
useJSXTextNode: true,
loggerFn: false,
warnOnUnsupportedTypeScriptVersion: false
});
});
});
@@ -42,7 +42,6 @@
"typescript": "*"
},
"devDependencies": {
"@typescript-eslint/shared-fixtures": "1.2.0",
"typescript": "~3.2.1"
"@typescript-eslint/shared-fixtures": "1.2.0"
}
}
@@ -18,9 +18,11 @@ import * as es from './typedefs';
import { Extra, ParserOptions } from './parser-options';
import { getFirstSemanticOrSyntacticError } from './semantic-errors';

const packageJSON = require('../package.json');

const SUPPORTED_TYPESCRIPT_VERSIONS = packageJSON.devDependencies.typescript;
/**
* This needs to be kept in sync with the top-level README.md in the
* typescript-eslint monorepo
*/
const SUPPORTED_TYPESCRIPT_VERSIONS = '>=3.2.1 <3.4.0';
const ACTIVE_TYPESCRIPT_VERSION = ts.version;
const isRunningSupportedTypeScriptVersion = semver.satisfies(
ACTIVE_TYPESCRIPT_VERSION,
@@ -287,7 +289,7 @@ interface ParseAndGenerateServicesResult<T extends ParserOptions> {
// Public
//------------------------------------------------------------------------------

export const version: string = packageJSON.version;
export const version: string = require('../package.json').version;

export function parse<T extends ParserOptions = ParserOptions>(
code: string,

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit f513a14

Please sign in to comment.