Skip to content

Commit 5d2b962

Browse files
piecykbradzacher
authored andcommitted
feat(*): support TypeScript versions >=3.2.1 <3.6.0 (#597)
1 parent c03b6ed commit 5d2b962

File tree

13 files changed

+25
-38
lines changed

13 files changed

+25
-38
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ The `canary` (latest master) version is:
203203

204204
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.
205205

206-
**The version range of TypeScript currently supported by this parser is `>=3.2.1 <3.5.0`.**
206+
**The version range of TypeScript currently supported by this parser is `>=3.2.1 <3.6.0`.**
207207

208208
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.
209209

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,6 @@
7878
"ts-jest": "^24.0.0",
7979
"ts-node": "^8.0.1",
8080
"tslint": "^5.11.0",
81-
"typescript": ">=3.2.1 <3.5.0"
81+
"typescript": ">=3.2.1 <3.6.0"
8282
}
8383
}

packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,7 @@ export default createRule<Options, MessageIds>({
15881588
);
15891589

15901590
// For each ignored node selector, set up a listener to collect it into the `ignoredNodes` set.
1591-
const ignoredNodes = new Set();
1591+
const ignoredNodes = new Set<TSESTree.Node>();
15921592

15931593
/**
15941594
* Ignores a node

packages/eslint-plugin/src/rules/semi.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default util.createRule<Options, MessageIds>({
5252
AST_NODE_TYPES.TSImportEqualsDeclaration,
5353
AST_NODE_TYPES.TSTypeAliasDeclaration,
5454
].reduce<TSESLint.RuleListener>((acc, node) => {
55-
acc[node] = checkForSemicolon;
55+
acc[node as string] = checkForSemicolon;
5656
return acc;
5757
}, {});
5858

packages/eslint-plugin/tests/configs/all.test.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
import rules from '../../src/rules';
22
import allConfig from '../../src/configs/all.json';
3-
import { TSESLint } from '@typescript-eslint/experimental-utils';
43

5-
interface IndexRules {
6-
[name: string]: TSESLint.RuleModule<string, any, any>;
7-
}
84
interface JsonRules {
95
[name: string]: string;
106
}
117

128
describe('all.json config', () => {
139
const RULE_NAME_PREFIX = '@typescript-eslint/';
1410

15-
const typedRules: IndexRules = rules;
16-
const notDeprecatedRuleNames = Object.keys(typedRules).reduce<string[]>(
11+
const rulesNames = Object.keys(rules) as (keyof typeof rules)[];
12+
const notDeprecatedRuleNames = rulesNames.reduce<string[]>(
1713
(collection, name) => {
18-
if (!typedRules[name].meta.deprecated) {
14+
if (!rules[name].meta.deprecated) {
1915
collection.push(`${RULE_NAME_PREFIX}${name}`);
2016
}
2117
return collection;

packages/eslint-plugin/tools/validate-docs/check-for-rule-docs.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import fs from 'fs';
33
import path from 'path';
44
import { logRule } from './log';
55

6-
function checkForRuleDocs(
7-
rules: Record<string, TSESLint.RuleModule<any, any>>,
6+
function checkForRuleDocs<TMessageIds extends string>(
7+
rules: Record<string, TSESLint.RuleModule<TMessageIds, any, any>>,
88
): boolean {
99
const ruleDocs = new Set(
1010
fs.readdirSync(path.resolve(__dirname, '../../docs/rules')),

packages/eslint-plugin/tools/validate-docs/validate-table-rules.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import marked from 'marked';
55
import path from 'path';
66
import { logRule } from './log';
77

8-
function validateTableRules(
9-
rules: Record<string, TSESLint.RuleModule<any, any>>,
8+
function validateTableRules<TMessageIds extends string>(
9+
rules: Record<string, TSESLint.RuleModule<TMessageIds, any, any>>,
1010
rulesTable: marked.Tokens.Table,
1111
): boolean {
1212
let hasErrors = false;

packages/eslint-plugin/tools/validate-docs/validate-table-structure.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import chalk from 'chalk';
33
import marked from 'marked';
44
import { logError } from './log';
55

6-
function validateTableStructure(
7-
rules: Record<string, TSESLint.RuleModule<any, any>>,
6+
function validateTableStructure<TMessageIds extends string>(
7+
rules: Record<string, TSESLint.RuleModule<TMessageIds, any, any>>,
88
rulesTable: marked.Tokens.Table,
99
): boolean {
1010
const ruleNames = Object.keys(rules).sort();

packages/experimental-utils/src/eslint-utils/RuleCreator.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,11 @@ import {
77
} from '../ts-eslint/Rule';
88
import { applyDefault } from './applyDefault';
99

10-
// Utility type to remove a list of properties from an object
11-
type RemoveProps<
12-
TObj extends Record<string, any>,
13-
TKeys extends keyof TObj
14-
> = Pick<TObj, Exclude<keyof TObj, TKeys>>;
15-
1610
// we'll automatically add the url + tslint description for people.
17-
type CreateRuleMetaDocs = RemoveProps<RuleMetaDataDocs, 'url'>;
11+
type CreateRuleMetaDocs = Omit<RuleMetaDataDocs, 'url'>;
1812
type CreateRuleMeta<TMessageIds extends string> = {
1913
docs: CreateRuleMetaDocs;
20-
} & RemoveProps<RuleMetaData<TMessageIds>, 'docs'>;
14+
} & Omit<RuleMetaData<TMessageIds>, 'docs'>;
2115

2216
export function RuleCreator(urlCreator: (ruleName: string) => string) {
2317
// This function will get much easier to call when this is merged https://github.com/Microsoft/TypeScript/pull/26349

packages/experimental-utils/src/eslint-utils/deepMerge.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export type ObjectLike<T = any> = Record<string, T>;
1+
type ObjectLike<T = any> = Record<string, T>;
22

33
/**
44
* Check if the variable contains an object stricly rejecting arrays
@@ -16,14 +16,11 @@ export function isObjectNotArray<T extends object>(obj: T | any[]): obj is T {
1616
* @param second The second object
1717
* @returns a new object
1818
*/
19-
export function deepMerge<T extends ObjectLike = ObjectLike>(
20-
first: ObjectLike = {},
21-
second: ObjectLike = {},
22-
): T {
19+
export function deepMerge(first: ObjectLike = {}, second: ObjectLike = {}) {
2320
// get the unique set of keys across both objects
2421
const keys = new Set(Object.keys(first).concat(Object.keys(second)));
2522

26-
return Array.from(keys).reduce<T>(
23+
return Array.from(keys).reduce(
2724
(acc, key) => {
2825
const firstHasKey = key in first;
2926
const secondHasKey = key in second;
@@ -44,6 +41,6 @@ export function deepMerge<T extends ObjectLike = ObjectLike>(
4441

4542
return acc;
4643
},
47-
{} as T,
44+
{} as ObjectLike,
4845
);
4946
}

packages/typescript-estree/src/parser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
* This needs to be kept in sync with the top-level README.md in the
1616
* typescript-eslint monorepo
1717
*/
18-
const SUPPORTED_TYPESCRIPT_VERSIONS = '>=3.2.1 <3.5.0';
18+
const SUPPORTED_TYPESCRIPT_VERSIONS = '>=3.2.1 <3.6.0';
1919
const ACTIVE_TYPESCRIPT_VERSION = ts.version;
2020
const isRunningSupportedTypeScriptVersion = semver.satisfies(
2121
ACTIVE_TYPESCRIPT_VERSION,

packages/typescript-estree/tests/lib/__snapshots__/convert.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Object {
3434
},
3535
"isDeclarationFile": false,
3636
"languageVariant": 1,
37-
"languageVersion": 7,
37+
"languageVersion": 8,
3838
"libReferenceDirectives": Array [],
3939
"lineMap": Array [
4040
null,

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -7155,10 +7155,10 @@ typedarray@^0.0.6:
71557155
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
71567156
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
71577157

7158-
"typescript@>=3.2.1 <3.5.0":
7159-
version "3.4.5"
7160-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.4.5.tgz#2d2618d10bb566572b8d7aad5180d84257d70a99"
7161-
integrity sha512-YycBxUb49UUhdNMU5aJ7z5Ej2XGmaIBL0x34vZ82fn3hGvD+bgrMrVDpatgz2f7YxUMJxMkbWxJZeAvDxVe7Vw==
7158+
"typescript@>=3.2.1 <3.6.0":
7159+
version "3.5.1"
7160+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.1.tgz#ba72a6a600b2158139c5dd8850f700e231464202"
7161+
integrity sha512-64HkdiRv1yYZsSe4xC1WVgamNigVYjlssIoaH2HcZF0+ijsk5YK2g0G34w9wJkze8+5ow4STd22AynfO6ZYYLw==
71627162

71637163
uglify-js@^3.1.4:
71647164
version "3.5.10"

0 commit comments

Comments
 (0)