Skip to content

Commit 0dd71f9

Browse files
committed
1 parent 603250a commit 0dd71f9

File tree

6 files changed

+72
-7
lines changed

6 files changed

+72
-7
lines changed

__tests__/__snapshots__/dist.typescript.ts.snap

+39
Original file line numberDiff line numberDiff line change
@@ -236,3 +236,42 @@ exports[`Typescript 3.9 detects errors 13`] = `"141:34 - Argument of type '1' is
236236
exports[`Typescript 3.9 detects errors 14`] = `"142:35 - Type '1' is not assignable to type 'Width<0 | (string & {})>'."`;
237237

238238
exports[`Typescript 3.9 detects errors 15`] = `"146:38 - Namespace '\\"index\\"' has no exported member 'DataType'."`;
239+
240+
exports[`Typescript 4.0 detects errors 1`] = `
241+
"45:2 - Type '{ unknownProperty: number; }' is not assignable to type 'Properties<0 | (string & {}), string & {}>'.
242+
Object literal may only specify known properties, and 'unknownProperty' does not exist in type 'Properties<0 | (string & {}), string & {}>'."
243+
`;
244+
245+
exports[`Typescript 4.0 detects errors 2`] = `"49:11 - Type 'number' is not assignable to type 'string'."`;
246+
247+
exports[`Typescript 4.0 detects errors 3`] = `"50:10 - Type 'number' is not assignable to type 'string'."`;
248+
249+
exports[`Typescript 4.0 detects errors 4`] = `
250+
"55:6 - Type '{}' is not assignable to type 'string & {}'.
251+
Type '{}' is not assignable to type 'string'."
252+
`;
253+
254+
exports[`Typescript 4.0 detects errors 5`] = `
255+
"60:10 - Type '\\"auto\\" | (string & {})' is not assignable to type '\\"auto\\"'.
256+
Type 'string & {}' is not assignable to type '\\"auto\\"'."
257+
`;
258+
259+
exports[`Typescript 4.0 detects errors 6`] = `"67:6 - Type '1' is not assignable to type 'string | 0'."`;
260+
261+
exports[`Typescript 4.0 detects errors 7`] = `"79:23 - This condition will always return 'false' since the types 'string | 0 | (string | 0)[]' and '1' have no overlap."`;
262+
263+
exports[`Typescript 4.0 detects errors 8`] = `"93:25 - This condition will always return 'false' since the types 'string | 0' and '1' have no overlap."`;
264+
265+
exports[`Typescript 4.0 detects errors 9`] = `"103:14 - Argument of type '1' is not assignable to parameter of type 'string | 0 | (string | 0)[]'."`;
266+
267+
exports[`Typescript 4.0 detects errors 10`] = `"104:15 - Type '1' is not assignable to type 'string | 0'."`;
268+
269+
exports[`Typescript 4.0 detects errors 11`] = `"117:23 - This condition will always return 'false' since the types 'string | 0 | (string | 0)[]' and '1' have no overlap."`;
270+
271+
exports[`Typescript 4.0 detects errors 12`] = `"131:25 - This condition will always return 'false' since the types 'string | 0' and '1' have no overlap."`;
272+
273+
exports[`Typescript 4.0 detects errors 13`] = `"141:34 - Argument of type '1' is not assignable to parameter of type '0 | \\"auto\\" | \\"inherit\\" | (string & {}) | \\"-moz-initial\\" | \\"initial\\" | \\"revert\\" | \\"unset\\" | \\"-moz-max-content\\" | \\"-moz-min-content\\" | \\"max-content\\" | \\"min-content\\" | \\"-webkit-max-content\\" | \\"intrinsic\\" | \\"min-intrinsic\\" | [...]'."`;
274+
275+
exports[`Typescript 4.0 detects errors 14`] = `"142:35 - Type '1' is not assignable to type 'Width<0 | (string & {})>'."`;
276+
277+
exports[`Typescript 4.0 detects errors 15`] = `"146:38 - Namespace '\\"index\\"' has no exported member 'DataType'."`;

__tests__/dist.typescript.ts

+21-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const COMPILER_OPTIONS = {
55
strict: true,
66
};
77

8-
describe('Typescript 3.9', () => {
8+
describe('Typescript 4.0', () => {
99
it('detects errors', async () => {
1010
const ts = await import('typescript');
1111
const program = ts.createProgram([path.resolve(__dirname, '__fixtures__/typecheck.ts')], COMPILER_OPTIONS);
@@ -17,6 +17,26 @@ describe('Typescript 3.9', () => {
1717
)}`;
1818
});
1919

20+
expect(Number(ts.versionMajorMinor)).toBe(4.0);
21+
expect(errors.length).toBe(15);
22+
for (const error of errors) {
23+
expect(error).toMatchSnapshot();
24+
}
25+
});
26+
});
27+
28+
describe('Typescript 3.9', () => {
29+
it('detects errors', async () => {
30+
const ts = await import('typescript3.9');
31+
const program = ts.createProgram([path.resolve(__dirname, '__fixtures__/typecheck.ts')], COMPILER_OPTIONS);
32+
const diagnostics = ts.getPreEmitDiagnostics(program);
33+
const errors = diagnostics.map(diagnostic => {
34+
const { line, character } = diagnostic.file!.getLineAndCharacterOfPosition(diagnostic.start!);
35+
return `${line}:${character} - ${removeAbsolutePaths(
36+
ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'),
37+
)}`;
38+
});
39+
2040
expect(Number(ts.versionMajorMinor)).toBe(3.9);
2141
expect(errors.length).toBe(15);
2242
for (const error of errors) {

__tests__/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"typescript3.5": "npm:[email protected]",
55
"typescript3.6": "npm:[email protected]",
66
"typescript3.7": "npm:[email protected]",
7-
"typescript3.8": "npm:[email protected]"
7+
"typescript3.8": "npm:[email protected]",
8+
"typescript3.9": "npm:[email protected]"
89
}
910
}

__tests__/yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,8 @@
2121
version "3.8.3"
2222
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061"
2323
integrity sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==
24+
25+
"typescript3.9@npm:[email protected]":
26+
version "3.9.7"
27+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa"
28+
integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"tslint": "^6.1.2",
3030
"tslint-config-prettier": "^1.18.0",
3131
"turndown": "^6.0.0",
32-
"typescript": "~3.9.7",
32+
"typescript": "~4.0.1-rc",
3333
"yarn": "^1.22.4"
3434
},
3535
"scripts": {

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -3630,10 +3630,10 @@ typedarray-to-buffer@^3.1.5:
36303630
dependencies:
36313631
is-typedarray "^1.0.0"
36323632

3633-
typescript@~3.9.7:
3634-
version "3.9.7"
3635-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa"
3636-
integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==
3633+
typescript@~4.0.1-rc:
3634+
version "4.0.1-rc"
3635+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.1-rc.tgz#8adc78223eae56fe71d906a5fa90c3543b07a677"
3636+
integrity sha512-TCkspT3dSKOykbzS3/WSK7pqU2h1d/lEO6i45Afm5Y3XNAEAo8YXTG3kHOQk/wFq/5uPyO1+X8rb/Q+g7UsxJw==
36373637

36383638
union-value@^1.0.0:
36393639
version "1.0.1"

0 commit comments

Comments
 (0)