Skip to content

Commit

Permalink
Running unit tests with TypeScript 5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
fasttime committed Nov 21, 2023
1 parent 30d2433 commit bae7f74
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 29 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
node-version: ^20.8
- run: |
npm install
gulp make-ts-defs
Expand All @@ -35,11 +35,11 @@ jobs:

strategy:
matrix:
node-version: ['16.0.0', '16', '18', '20']
node-version: ['16.0.0', '16', '18', '20', '21']

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
deno-version: [v1.24, v1.x]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ matrix.deno-version }}
Expand Down
14 changes: 5 additions & 9 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ task

const JS_EXAMPLE_RULES =
{
'comma-dangle':
'@stylistic/comma-dangle':
[
'error',
{
Expand All @@ -123,14 +123,10 @@ task
varsIgnorePattern: '^(?:Green|WhiteUnit)Circle$',
},
],
'quotes': ['error', 'double'],
'@stylistic/quotes': ['error', 'double'],
};
const TS_EXAMPLE_RULES =
Object.fromEntries
(
Object.entries(JS_EXAMPLE_RULES)
.map(([key, value]) => [`@typescript-eslint/${key}`, value]),
);
const { 'no-unused-vars': noUnusedVars, ...TS_EXAMPLE_RULES } = JS_EXAMPLE_RULES;
TS_EXAMPLE_RULES['@typescript-eslint/no-unused-vars'] = noUnusedVars;
const overrideConfig =
createConfig
(
Expand Down Expand Up @@ -160,7 +156,7 @@ task
},
{
files: 'lib/**/*.d.ts',
rules: { 'max-len': 'off' },
rules: { '@stylistic/max-len': 'off' },
},
{
files: '*.tstest',
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"typescript_4.9": "npm:[email protected]",
"typescript_5.0": "npm:[email protected]",
"typescript_5.1": "npm:[email protected]",
"typescript_5.2": "npm:[email protected]"
"typescript_5.2": "npm:[email protected]",
"typescript_5.3": "npm:[email protected]"
},
"engines": {
"node": ">=16.0.0"
Expand Down
3 changes: 2 additions & 1 deletion test/eslint-plugin-tstest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ function preprocess(text, filename)
fileNameToTestCaseMap.set(filename, testCase);
const polytypeMode = testCase.polytypeMode ?? 'global';
const importStatement = getImportStatement(polytypeMode);
const testDataText = `void\n${testCase.testData}\n; // eslint-disable-line semi-style\n`;
const testDataText =
`void\n${testCase.testData}\n; // eslint-disable-line @stylistic/semi-style\n`;
const processedCode = processTestCase(testCase, importStatement);
const returnValue =
[{ text: processedCode, filename: '/..' }, { text: testDataText, filename: '/test-data.mjs' }];
Expand Down
17 changes: 17 additions & 0 deletions test/spec/ts-defs.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,22 @@ function defineTests(typescriptPkgName)
`${actualMessagesString}`,
);
}
else if (Array.isArray(expectedMessage))
{
assert.equal
(
actualErrorCount,
1,
`expected exactly 1 compiler error, but got ${actualErrorCount}:` +
`${actualMessagesString}`,
);
const [actualMessage] = testCase.actualMessages;
assert
(
expectedMessage.includes(actualMessage),
`Actual message:\n${actualMessage}`,
);
}
else
{
assert.equal
Expand Down Expand Up @@ -187,5 +203,6 @@ describe
describe('TypeScript 5.0', () => defineTests('typescript_5.0'));
describe('TypeScript 5.1', () => defineTests('typescript_5.1'));
describe('TypeScript 5.2', () => defineTests('typescript_5.2'));
describe('TypeScript 5.3', () => defineTests('typescript_5.3'));
},
);
36 changes: 25 additions & 11 deletions test/spec/ts-defs/110.tstest
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,31 @@
{
title: 'Superconstructor argument referencing indirect superclass',
expectedMessage:
'No overload matches this call.\n' +
' Overload 1 of 2, \'(args_0?: readonly [] | undefined): ClusteredPrototype<[typeof B]>\', ' +
'gave the following error.\n' +
' Argument of type \'{ super: typeof A; }\' is not assignable to parameter of type ' +
'\'readonly []\'.\n' +
' Object literal may only specify known properties, and \'super\' does not exist in ' +
'type \'readonly []\'.\n' +
' Overload 2 of 2, \'(...args: Readonly<SuperConstructorInvokeInfo<typeof B>>[]): ' +
'ClusteredPrototype<[typeof B]>\', gave the following error.\n' +
' Type \'typeof A\' is not assignable to type \'typeof B\'.\n' +
' Property \'b\' is missing in type \'A\' but required in type \'B\'.',
[
// TypeScript < 5.3
'No overload matches this call.\n' +
' Overload 1 of 2, \'(args_0?: readonly [] | undefined): ClusteredPrototype<[typeof ' +
'B]>\', gave the following error.\n' +
' Argument of type \'{ super: typeof A; }\' is not assignable to parameter of type ' +
'\'readonly []\'.\n' +
' Object literal may only specify known properties, and \'super\' does not exist in ' +
'type \'readonly []\'.\n' +
' Overload 2 of 2, \'(...args: Readonly<SuperConstructorInvokeInfo<typeof B>>[]): ' +
'ClusteredPrototype<[typeof B]>\', gave the following error.\n' +
' Type \'typeof A\' is not assignable to type \'typeof B\'.\n' +
' Property \'b\' is missing in type \'A\' but required in type \'B\'.',

// TypeScript >= 5.3
'No overload matches this call.\n' +
' Overload 1 of 2, \'(args_0?: readonly [] | undefined): ClusteredPrototype<[typeof ' +
'B]>\', gave the following error.\n' +
' Object literal may only specify known properties, and \'super\' does not exist in ' +
'type \'readonly []\'.\n' +
' Overload 2 of 2, \'(...args: Readonly<SuperConstructorInvokeInfo<typeof B>>[]): ' +
'ClusteredPrototype<[typeof B]>\', gave the following error.\n' +
' Type \'typeof A\' is not assignable to type \'typeof B\'.\n' +
' Property \'b\' is missing in type \'A\' but required in type \'B\'.',
],
}
*/

Expand Down

0 comments on commit bae7f74

Please sign in to comment.