Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rely on TypeScript 4.7 and update integration + tests
* Only test against TypeScript 4.7 * Move type definitions to entrypoints/ Only TS 4.7 will resolve them now, but it's cleaner. * Use @sindresorhus/tsconfig * Fix test TypeScript files, make compilable and lintable * Use tsc directly, instead of tsd * Add *.cts versions of type tests * Reorganize type tests * Use tsc directly, avoid npx, print actual version Somehow `npx tsc` was pointing at an older version. Possibly the binstubs are corrupted in CI… somehow.
- Loading branch information
1 parent
d0af729
commit 02f4e27
Showing
45 changed files
with
532 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export {default} from './main.js'; | ||
export * from './main.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type {TestFn} from '../types/test-fn.js'; | ||
|
||
export * from '../types/assertions.js'; | ||
export * from '../types/try-fn.js'; | ||
export * from '../types/test-fn.js'; | ||
export * from '../types/subscribable.js'; | ||
|
||
/** Call to declare a test, or chain to declare hooks or test modifiers */ | ||
declare const test: TestFn; | ||
|
||
/** Call to declare a test, or chain to declare hooks or test modifiers */ | ||
export default test; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from '../plugin.js' | ||
export * from './plugin.js' |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
test-tap/fixture/snapshots/test-sourcemaps/src/feature/__tests__/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import test from 'ava'; | ||
import {expectType} from 'tsd'; | ||
|
||
type Expected = {foo: 'bar'}; | ||
const expected: Expected = {foo: 'bar'}; | ||
|
||
test('deepEqual', t => { | ||
const actual: unknown = {}; | ||
if (t.deepEqual(actual, expected)) { | ||
expectType<Expected>(actual); | ||
} | ||
}); | ||
|
||
test('like', t => { | ||
const actual: unknown = {}; | ||
if (t.like(actual, expected)) { | ||
expectType<Expected>(actual); | ||
} | ||
}); | ||
|
||
test('is', t => { | ||
const actual: unknown = 2; | ||
if (t.is(actual, 3 as const)) { | ||
expectType<3>(actual); | ||
} | ||
}); | ||
|
||
test('false', t => { | ||
const actual: unknown = true; | ||
if (t.false(actual)) { | ||
expectType<false>(actual); | ||
} | ||
}); | ||
|
||
test('true', t => { | ||
const actual: unknown = false; | ||
if (t.true(actual)) { | ||
expectType<true>(actual); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* eslint-disable @typescript-eslint/no-empty-function */ | ||
import anyTest, {ExecutionContext, TestFn} from 'ava'; | ||
import {expectError, expectType} from 'tsd'; | ||
|
||
interface Context { | ||
foo: string; | ||
} | ||
|
||
const test = anyTest as TestFn<Context>; | ||
|
||
const macro = test.macro((t, _expected: number) => { | ||
expectType<string>(t.context.foo); | ||
}); | ||
|
||
test.beforeEach(t => { | ||
expectType<Context>(t.context); | ||
}); | ||
|
||
// @ts-expect-error TS2769 | ||
expectError(test('foo is bar', macro, 'bar')); // eslint-disable-line @typescript-eslint/no-confusing-void-expression | ||
|
||
anyTest('default context is unknown', t => { | ||
expectType<unknown>(t.context); | ||
}); | ||
|
||
// See https://github.com/avajs/ava/issues/2253 | ||
interface Covariant extends Context { | ||
bar: number; | ||
} | ||
|
||
const test2 = anyTest as TestFn<Covariant>; | ||
const hook = (_t: ExecutionContext<Context>) => {}; | ||
test2.beforeEach(hook); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import test from 'ava'; | ||
import {expectType} from 'tsd'; | ||
|
||
test('actual extends expected', t => { | ||
type Expected = {foo: [1, 2, 3]}; | ||
const expected: Expected = {foo: [1, 2, 3]}; | ||
const actual = {foo: [1, 2, 3]}; | ||
if (t.deepEqual(actual, expected)) { | ||
expectType<Expected>(actual); | ||
} | ||
}); | ||
|
||
test('expected extends actual', t => { | ||
type Expected = {foo: Array<number | string>}; | ||
type Actual = {foo: number[]}; | ||
const expected: Expected = {foo: [1, 2, 3]}; | ||
const actual: Actual = {foo: [1, 2, 3]}; | ||
if (t.deepEqual(actual, expected)) { | ||
expectType<Actual>(expected); | ||
} | ||
}); | ||
|
||
test('neither extends the each other', t => { | ||
type Expected = {readonly foo: readonly [1, 2, 3]}; | ||
type Actual = {foo: number[]}; | ||
const expected: Expected = {foo: [1, 2, 3]}; | ||
const actual: Actual = {foo: [1, 2, 3]}; | ||
t.deepEqual(actual, expected); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* eslint-disable @typescript-eslint/no-empty-function */ | ||
import test from 'ava'; | ||
|
||
test.after('return anything else', _t => ({ | ||
foo: 'bar', | ||
subscribe() {}, | ||
then() {}, // eslint-disable-line unicorn/no-thenable | ||
})); | ||
|
||
test('return a promise-like', _t => ({ | ||
then(resolve) { // eslint-disable-line unicorn/no-thenable | ||
resolve?.(); // eslint-disable-line @typescript-eslint/no-floating-promises | ||
}, | ||
})); | ||
|
||
test('return a subscribable', _t => ({ | ||
subscribe({complete}) { | ||
complete(); | ||
}, | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import test from 'ava'; | ||
|
||
test('like', t => { | ||
t.like({ | ||
map: new Map([['foo', 'bar']]), | ||
nested: { | ||
baz: 'thud', | ||
qux: 'quux', | ||
}, | ||
}, { | ||
map: new Map([['foo', 'bar']]), | ||
nested: { | ||
baz: 'thud', | ||
}, | ||
}); | ||
|
||
type Foo = { | ||
foo?: 'foo'; | ||
bar?: 'bar'; | ||
}; | ||
|
||
const foo: Foo = {bar: 'bar'}; | ||
const {foo: _, ...expected} = foo; | ||
t.like(expected, {bar: 'bar'}); | ||
}); |
Oops, something went wrong.