Skip to content

Commit 480e70e

Browse files
committed
feat: remove support for TypeScript < 3.6.0
BREAKING CHANGE: 🧨 Drop support for TypeScript < 3.6.0
1 parent acc7d12 commit 480e70e

10 files changed

+40
-65
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@
7575
"tapable": "^2.0.0"
7676
},
7777
"peerDependencies": {
78-
"webpack": "^5.11.0"
78+
"webpack": "^5.11.0",
79+
"typescript": ">3.6.0"
7980
},
8081
"devDependencies": {
8182
"@commitlint/config-conventional": "^11.0.0",

src/typescript-reporter/TypeScriptSupport.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,11 @@ function assertTypeScriptSupport(configuration: TypeScriptReporterConfiguration)
1717
);
1818
}
1919

20-
if (semver.lt(typescriptVersion, '2.7.0')) {
20+
if (semver.lt(typescriptVersion, '3.6.0')) {
2121
throw new Error(
2222
[
2323
`ForkTsCheckerWebpackPlugin cannot use the current typescript version of ${typescriptVersion}.`,
24-
'The minimum required version is 2.7.0.',
25-
].join(os.EOL)
26-
);
27-
}
28-
29-
if (configuration.build && semver.lt(typescriptVersion, '3.6.0')) {
30-
throw new Error(
31-
[
32-
`ForkTsCheckerWebpackPlugin cannot use the current typescript version of ${typescriptVersion} because of the "build" option enabled.`,
33-
'The minimum version that supports "build" option is 3.6.0.',
34-
'Consider upgrading `typescript` or disabling "build" option.',
24+
'The minimum required version is 3.6.0.',
3525
].join(os.EOL)
3626
);
3727
}

src/typescript-reporter/reporter/ControlledTypeScriptSystem.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,8 @@ function createControlledTypeScriptSystem(
103103

104104
const fileWatcherCallbacks = fileWatcherCallbacksMap.get(normalizedPath);
105105
if (fileWatcherCallbacks) {
106-
// typescript expects normalized paths with posix forward slash
107106
fileWatcherCallbacks.forEach((fileWatcherCallback) =>
108-
fileWatcherCallback(forwardSlash(normalizedPath), event)
107+
fileWatcherCallback(normalizedPath, event)
109108
);
110109
}
111110
}
@@ -121,7 +120,7 @@ function createControlledTypeScriptSystem(
121120
const directoryWatcherCallbacks = directoryWatcherCallbacksMap.get(directory);
122121
if (directoryWatcherCallbacks) {
123122
directoryWatcherCallbacks.forEach((directoryWatcherCallback) =>
124-
directoryWatcherCallback(forwardSlash(normalizedPath))
123+
directoryWatcherCallback(normalizedPath)
125124
);
126125
}
127126

@@ -133,7 +132,7 @@ function createControlledTypeScriptSystem(
133132
forwardSlash(directory)[watchedDirectory.length] === '/')
134133
) {
135134
recursiveDirectoryWatcherCallbacks.forEach((recursiveDirectoryWatcherCallback) =>
136-
recursiveDirectoryWatcherCallback(forwardSlash(normalizedPath))
135+
recursiveDirectoryWatcherCallback(normalizedPath)
137136
);
138137
}
139138
}

test/e2e/TypeScriptConfiguration.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import {
66

77
describe('TypeScript Configuration', () => {
88
it.each([
9-
{ async: true, typescript: '2.7.1', 'ts-loader': '^5.0.0' },
10-
{ async: false, typescript: '~3.0.0', 'ts-loader': '^6.0.0' },
11-
{ async: true, typescript: '~3.7.0', 'ts-loader': '^7.0.0' },
12-
{ async: false, typescript: '~3.8.0', 'ts-loader': '^6.0.0' },
9+
{ async: true, typescript: '~3.6.0', 'ts-loader': '^7.0.0' },
10+
{ async: false, typescript: '~3.8.0', 'ts-loader': '^8.0.0' },
11+
{ async: true, typescript: '~4.0.0', 'ts-loader': '^8.0.0' },
12+
{ async: false, typescript: '~4.3.0', 'ts-loader': '^8.0.0' },
1313
])(
1414
'change in the tsconfig.json affects compilation for %p',
1515
async ({ async, ...dependencies }) => {
@@ -39,10 +39,10 @@ describe('TypeScript Configuration', () => {
3939
);
4040

4141
it.each([
42-
{ typescript: '2.7.1' },
43-
{ typescript: '~3.0.0' },
4442
{ typescript: '~3.6.0' },
4543
{ typescript: '^3.8.0' },
44+
{ typescript: '^4.0.0' },
45+
{ typescript: '^4.3.0' },
4646
])('reports errors because of the misconfiguration', async (dependencies) => {
4747
await sandbox.load(path.join(__dirname, 'fixtures/typescript-basic'));
4848
await sandbox.install('yarn', { ...dependencies });

test/e2e/TypeScriptContextOption.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { createWebpackDevServerDriver } from './driver/WebpackDevServerDriver';
44

55
describe('TypeScript Context Option', () => {
66
it.each([
7-
{ async: true, typescript: '2.7.1' },
8-
{ async: false, typescript: '~3.0.0' },
97
{ async: true, typescript: '~3.6.0' },
108
{ async: false, typescript: '~3.8.0' },
9+
{ async: true, typescript: '~4.0.0' },
10+
{ async: false, typescript: '~4.3.0' },
1111
])('uses context and cwd to resolve project files for %p', async ({ async, typescript }) => {
1212
await sandbox.load(path.join(__dirname, 'fixtures/typescript-basic'));
1313
await sandbox.install('yarn', { typescript });

test/e2e/TypeScriptFormatterOption.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { createWebpackDevServerDriver } from './driver/WebpackDevServerDriver';
44
describe('TypeScript Formatter Option', () => {
55
it.each([
66
{ async: true, typescript: '~3.6.0' },
7-
{ async: false, typescript: '~3.8.0' },
7+
{ async: false, typescript: '~4.3.0' },
88
])(
99
'uses the custom formatter to format the error message for %p',
1010
async ({ async, typescript }) => {

test/e2e/TypeScriptPnpSupport.spec.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import path from 'path';
22
import { createWebpackDevServerDriver } from './driver/WebpackDevServerDriver';
3+
import semver from 'semver';
34

45
describe('TypeScript PnP Support', () => {
56
it.each([
6-
{ async: true, typescript: '2.7.1', 'ts-loader': '^5.0.0' },
7-
{ async: false, typescript: '~3.0.0', 'ts-loader': '^6.0.0' },
8-
{ async: true, typescript: '~3.8.0', 'ts-loader': '^7.0.0' },
7+
{ async: true, typescript: '~3.6.0', 'ts-loader': '^7.0.0' },
8+
{ async: false, typescript: '~4.0.0', 'ts-loader': '^8.0.0' },
9+
{ async: true, typescript: '~4.3.0', 'ts-loader': '^8.0.0' },
910
])('reports semantic error for %p', async ({ async, ...dependencies }) => {
1011
await sandbox.load(path.join(__dirname, 'fixtures/typescript-pnp'));
1112
await sandbox.install('yarn', { ...dependencies });
@@ -70,7 +71,9 @@ describe('TypeScript PnP Support', () => {
7071
expect(errors).toContain(
7172
[
7273
'ERROR in ./src/index.ts 1:23-39',
73-
"TS2307: Cannot find module './authenticate'.",
74+
semver.satisfies(semver.minVersion(dependencies.typescript), '>=4.0.0')
75+
? "TS2307: Cannot find module './authenticate' or its corresponding type declarations."
76+
: "TS2307: Cannot find module './authenticate'.",
7477
" > 1 | import { login } from './authenticate';",
7578
' | ^^^^^^^^^^^^^^^^',
7679
" 2 | import { getUserName } from './model/User';",

test/e2e/TypeScriptSolutionBuilderApi.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import path from 'path';
22
import { createWebpackDevServerDriver } from './driver/WebpackDevServerDriver';
3+
import semver from 'semver';
34

45
describe('TypeScript SolutionBuilder API', () => {
56
it.each([
67
{ async: false, typescript: '~3.6.0', mode: 'readonly' },
78
{ async: true, typescript: '~3.8.0', mode: 'write-tsbuildinfo' },
8-
{ async: false, typescript: '~3.8.0', mode: 'write-references' },
9+
{ async: false, typescript: '~4.0.0', mode: 'write-references' },
10+
{ async: true, typescript: '~4.3.0', mode: 'readonly' },
911
])('reports semantic error for %p', async ({ async, typescript, mode }) => {
1012
await sandbox.load(path.join(__dirname, 'fixtures/typescript-monorepo'));
1113
await sandbox.install('yarn', { typescript });
@@ -53,7 +55,7 @@ describe('TypeScript SolutionBuilder API', () => {
5355
[
5456
'ERROR in ./packages/client/src/index.ts 4:42-48',
5557
"TS2345: Argument of type 'T[]' is not assignable to parameter of type 'T'.",
56-
typescript === '~4.0.0'
58+
semver.satisfies(semver.minVersion(typescript), '>=4.0.0')
5759
? " 'T' could be instantiated with an arbitrary type which could be unrelated to 'T[]'."
5860
: " 'T[]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.",
5961
' 2 |',

test/e2e/TypeScriptWatchApi.spec.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import path from 'path';
22
import { createWebpackDevServerDriver } from './driver/WebpackDevServerDriver';
3+
import semver from 'semver';
34

45
describe('TypeScript Watch API', () => {
56
it.each([{ async: false }, { async: true }])(
@@ -209,10 +210,10 @@ describe('TypeScript Watch API', () => {
209210
);
210211

211212
it.each([
212-
{ async: true, typescript: '2.7.1', 'ts-loader': '^5.0.0' },
213-
{ async: false, typescript: '~3.0.0', 'ts-loader': '^6.0.0' },
214-
{ async: true, typescript: '~3.6.0', 'ts-loader': '^7.0.0' },
215-
{ async: false, typescript: '~3.8.0', 'ts-loader': '^6.0.0' },
213+
{ async: true, typescript: '~3.6.0', 'ts-loader': '^6.0.0' },
214+
{ async: false, typescript: '~3.8.0', 'ts-loader': '^7.0.0' },
215+
{ async: true, typescript: '~4.0.0', 'ts-loader': '^8.0.0' },
216+
{ async: false, typescript: '~4.3.0', 'ts-loader': '^8.0.0' },
216217
])('reports semantic error for %p', async ({ async, ...dependencies }) => {
217218
await sandbox.load(path.join(__dirname, 'fixtures/typescript-basic'));
218219
await sandbox.install('yarn', { ...dependencies });
@@ -277,7 +278,9 @@ describe('TypeScript Watch API', () => {
277278
expect(errors).toContain(
278279
[
279280
'ERROR in ./src/index.ts 1:23-39',
280-
"TS2307: Cannot find module './authenticate'.",
281+
semver.satisfies(semver.minVersion(dependencies.typescript), '>=4.0.0')
282+
? "TS2307: Cannot find module './authenticate' or its corresponding type declarations."
283+
: "TS2307: Cannot find module './authenticate'.",
281284
" > 1 | import { login } from './authenticate';",
282285
' | ^^^^^^^^^^^^^^^^',
283286
" 2 | import { getUserName } from './model/User';",

test/unit/typescript-reporter/TypeScriptSupport.spec.ts

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -42,43 +42,20 @@ describe('typescript-reporter/TypeScriptSupport', () => {
4242
);
4343
});
4444

45-
it('throws error if typescript version is lower then 2.7.0', async () => {
46-
jest.setMock('typescript', { version: '2.6.9' });
47-
48-
const { assertTypeScriptSupport } = await import('lib/typescript-reporter/TypeScriptSupport');
49-
50-
expect(() => assertTypeScriptSupport(configuration)).toThrowError(
51-
[
52-
`ForkTsCheckerWebpackPlugin cannot use the current typescript version of 2.6.9.`,
53-
'The minimum required version is 2.7.0.',
54-
].join(os.EOL)
55-
);
56-
});
57-
58-
it("doesn't throw error if typescript version is greater or equal 2.7.0", async () => {
59-
jest.setMock('typescript', { version: '2.7.0' });
60-
jest.setMock('fs-extra', { existsSync: () => true });
61-
62-
const { assertTypeScriptSupport } = await import('lib/typescript-reporter/TypeScriptSupport');
63-
64-
expect(() => assertTypeScriptSupport(configuration)).not.toThrowError();
65-
});
66-
67-
it('throws error if typescript version is lower then 3.6.0 and configuration has enabled build option', async () => {
45+
it('throws error if typescript version is lower then 3.6.0', async () => {
6846
jest.setMock('typescript', { version: '3.5.9' });
6947

7048
const { assertTypeScriptSupport } = await import('lib/typescript-reporter/TypeScriptSupport');
7149

72-
expect(() => assertTypeScriptSupport({ ...configuration, build: true })).toThrowError(
50+
expect(() => assertTypeScriptSupport(configuration)).toThrowError(
7351
[
74-
`ForkTsCheckerWebpackPlugin cannot use the current typescript version of 3.5.9 because of the "build" option enabled.`,
75-
'The minimum version that supports "build" option is 3.6.0.',
76-
'Consider upgrading `typescript` or disabling "build" option.',
52+
`ForkTsCheckerWebpackPlugin cannot use the current typescript version of 3.5.9.`,
53+
'The minimum required version is 3.6.0.',
7754
].join(os.EOL)
7855
);
7956
});
8057

81-
it("doesn't throw error if typescript version is greater or equal 3.6.0 and configuration has enabled build option", async () => {
58+
it("doesn't throw error if typescript version is greater or equal 3.6.0", async () => {
8259
jest.setMock('typescript', { version: '3.6.0' });
8360
jest.setMock('fs-extra', { existsSync: () => true });
8461

0 commit comments

Comments
 (0)