Skip to content

Commit 15407be

Browse files
committed
Revert "Allow testing certain code blocks on only specific TypeScript versions"
This reverts commit 04c837a.
1 parent 04c837a commit 15407be

File tree

4 files changed

+3
-46
lines changed

4 files changed

+3
-46
lines changed

integrationTests/ts/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

integrationTests/ts/index.ts.template renamed to integrationTests/ts/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ const example: SomeExtension = {
1313
};
1414

1515
// The following code block requires a newer version of TypeScript
16-
/*! >=3.2 !*/
16+
/*! >=3.2
17+
1718
declare module 'graphql' {
1819
interface GraphQLObjectTypeExtensions<TSource = any, TContext = any> {
1920
someObjectExtension?: SomeExtension;
@@ -29,7 +30,7 @@ declare module 'graphql' {
2930
someArgumentExtension?: SomeExtension;
3031
}
3132
}
32-
/*!!*/
33+
*/
3334

3435
const queryType: GraphQLObjectType = new GraphQLObjectType({
3536
name: 'Query',

integrationTests/ts/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
"test": "node test.js"
44
},
55
"dependencies": {
6-
"glob": "^7.1.6",
76
"graphql": "file:../../npmDist",
8-
"semver": "^7.3.2",
97
"typescript-2.6": "npm:[email protected]",
108
"typescript-2.7": "npm:[email protected]",
119
"typescript-2.8": "npm:[email protected]",

integrationTests/ts/test.js

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,16 @@
44

55
const path = require('path');
66
const childProcess = require('child_process');
7-
const assert = require('assert');
8-
const fs = require('fs');
9-
10-
const glob = require('glob');
11-
const semver = require('semver');
127

138
const { dependencies } = require('./package.json');
149

1510
const tsVersions = Object.keys(dependencies)
1611
.filter((pkg) => pkg.startsWith('typescript-'))
1712
.sort((a, b) => b.localeCompare(a));
1813

19-
// To allow omitting certain code from older versions of TypeScript, we have a
20-
// "magic" comment syntax. We precede a block of code with:
21-
//
22-
// /*! SEMVER_RANGE !*/
23-
//
24-
// replacing SEMVER_RANGE with a semver range spec, such as '>=3.2'; we
25-
// terminate the block of code with:
26-
//
27-
// /*!!*/
28-
//
29-
// We will only include the code between these comments if the TypeScript
30-
// version being tested satisfies the semver range that was specified. NOTE: We
31-
// currently do not allow nesting of these blocks.
32-
const templates = glob.sync('./*.ts.template').map((filename) => {
33-
const content = fs.readFileSync(filename, 'utf8');
34-
const targetFilename = filename.replace(/\.template$/, '');
35-
assert.notEqual(filename, targetFilename);
36-
const writeFileSync = (version) => {
37-
// Captures our magic comment syntax: `/*!(CAPTURE1)!*/(CAPTURE 2)/*!!*/`
38-
const regex = /\/\*!([^!]+)!\*\/([\s\S]*?)\/\*!!\*\//g;
39-
const finalContent = content.replace(regex, (_, versionRange, payload) => {
40-
if (semver.satisfies(version, versionRange)) {
41-
return payload;
42-
}
43-
return '';
44-
});
45-
fs.writeFileSync(targetFilename, finalContent);
46-
};
47-
return { writeFileSync };
48-
});
49-
5014
for (const version of tsVersions) {
5115
console.log(`Testing on ${version} ...`);
5216

53-
for (const template of templates) {
54-
template.writeFileSync(version);
55-
}
56-
5717
const tscPath = path.join(__dirname, 'node_modules', version, 'bin/tsc');
5818
childProcess.execSync(tscPath, { stdio: 'inherit' });
5919
}

0 commit comments

Comments
 (0)