Skip to content

Commit f513a14

Browse files
authored
feat(*): change TypeScript version range to >=3.2.1 <3.4.0 (#184)
1 parent e37a1ed commit f513a14

File tree

10 files changed

+54
-15
lines changed

10 files changed

+54
-15
lines changed

Diff for: README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ The `canary` (latest master) version is:
4242

4343
## Supported TypeScript Version
4444

45-
We will always endeavor to support the latest stable version of TypeScript.
45+
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.
4646

47-
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.
47+
**The version range of TypeScript currently supported by this parser is `>=3.2.1 <3.4.0`.**
4848

49-
If you use a non-supported version of TypeScript, the parser will log a warning to the console.
49+
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.
50+
51+
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/).
5052

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

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@
6969
"rimraf": "^2.6.3",
7070
"ts-jest": "^23.10.4",
7171
"tslint": "^5.11.0",
72-
"typescript": "~3.2.1"
72+
"typescript": ">=3.2.1 <3.4.0"
7373
}
7474
}

Diff for: packages/eslint-plugin/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@
3434
},
3535
"peerDependencies": {
3636
"eslint": "^5.0.0",
37-
"typescript": "~3.2.1"
37+
"typescript": "*"
3838
}
3939
}

Diff for: packages/parser/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ The following additional configuration options are available by specifying them
5454

5555
- **`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
5656

57+
- **`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
58+
5759
### .eslintrc.json
5860

5961
```json

Diff for: packages/parser/src/parser-options.ts

+1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ export interface ParserOptions {
1717
errorOnTypeScriptSyntacticAndSemanticIssues?: boolean;
1818
tsconfigRootDir?: string;
1919
extraFileExtensions?: string[];
20+
warnOnUnsupportedTypeScriptVersion?: boolean;
2021
}

Diff for: packages/parser/src/parser.ts

+12
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ export function parseForESLint(
7575
}
7676
}
7777

78+
/**
79+
* Allow the user to suppress the warning from typescript-estree if they are using an unsupported
80+
* version of TypeScript
81+
*/
82+
const warnOnUnsupportedTypeScriptVersion = validateBoolean(
83+
options.warnOnUnsupportedTypeScriptVersion,
84+
true
85+
);
86+
if (!warnOnUnsupportedTypeScriptVersion) {
87+
parserOptions.loggerFn = false;
88+
}
89+
7890
const { ast, services } = parseAndGenerateServices(code, parserOptions);
7991
ast.sourceType = options.sourceType;
8092

Diff for: packages/parser/tests/lib/parser.ts

+21
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,25 @@ describe('parser', () => {
8484
`"Cannot assign to read only property 'ArrayExpression' of object '#<Object>'"`
8585
);
8686
});
87+
88+
it('`warnOnUnsupportedTypeScriptVersion: false` should set `loggerFn: false` on typescript-estree', () => {
89+
const code = 'const valid = true;';
90+
const spy = jest.spyOn(typescriptESTree, 'parseAndGenerateServices');
91+
parseForESLint(code, { warnOnUnsupportedTypeScriptVersion: true });
92+
expect(spy).toHaveBeenCalledWith(code, {
93+
ecmaFeatures: {},
94+
jsx: false,
95+
sourceType: 'script',
96+
useJSXTextNode: true
97+
});
98+
parseForESLint(code, { warnOnUnsupportedTypeScriptVersion: false });
99+
expect(spy).toHaveBeenCalledWith(code, {
100+
ecmaFeatures: {},
101+
jsx: false,
102+
sourceType: 'script',
103+
useJSXTextNode: true,
104+
loggerFn: false,
105+
warnOnUnsupportedTypeScriptVersion: false
106+
});
107+
});
87108
});

Diff for: packages/typescript-estree/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"typescript": "*"
4343
},
4444
"devDependencies": {
45-
"@typescript-eslint/shared-fixtures": "1.2.0",
46-
"typescript": "~3.2.1"
45+
"@typescript-eslint/shared-fixtures": "1.2.0"
4746
}
4847
}

Diff for: packages/typescript-estree/src/parser.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ import * as es from './typedefs';
1818
import { Extra, ParserOptions } from './parser-options';
1919
import { getFirstSemanticOrSyntacticError } from './semantic-errors';
2020

21-
const packageJSON = require('../package.json');
22-
23-
const SUPPORTED_TYPESCRIPT_VERSIONS = packageJSON.devDependencies.typescript;
21+
/**
22+
* This needs to be kept in sync with the top-level README.md in the
23+
* typescript-eslint monorepo
24+
*/
25+
const SUPPORTED_TYPESCRIPT_VERSIONS = '>=3.2.1 <3.4.0';
2426
const ACTIVE_TYPESCRIPT_VERSION = ts.version;
2527
const isRunningSupportedTypeScriptVersion = semver.satisfies(
2628
ACTIVE_TYPESCRIPT_VERSION,
@@ -287,7 +289,7 @@ interface ParseAndGenerateServicesResult<T extends ParserOptions> {
287289
// Public
288290
//------------------------------------------------------------------------------
289291

290-
export const version: string = packageJSON.version;
292+
export const version: string = require('../package.json').version;
291293

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

Diff for: yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -7056,10 +7056,10 @@ typedarray@^0.0.6:
70567056
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
70577057
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
70587058

7059-
typescript@~3.2.1:
7060-
version "3.2.2"
7061-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.2.2.tgz#fe8101c46aa123f8353523ebdcf5730c2ae493e5"
7062-
integrity sha512-VCj5UiSyHBjwfYacmDuc/NOk4QQixbE+Wn7MFJuS0nRuPQbof132Pw4u53dm264O8LPc2MVsc7RJNml5szurkg==
7059+
"typescript@>=3.2.1 <3.4.0":
7060+
version "3.3.1"
7061+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.3.1.tgz#6de14e1db4b8a006ac535e482c8ba018c55f750b"
7062+
integrity sha512-cTmIDFW7O0IHbn1DPYjkiebHxwtCMU+eTy30ZtJNBPF9j2O1ITu5XH2YnBeVRKWHqF+3JQwWJv0Q0aUgX8W7IA==
70637063

70647064
uglify-js@^3.1.4:
70657065
version "3.4.9"

0 commit comments

Comments
 (0)