Skip to content

Commit

Permalink
fix some compile errors & busted imports
Browse files Browse the repository at this point in the history
  • Loading branch information
DetachHead committed Apr 11, 2023
1 parent 4a1ae39 commit 26e1837
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 16 deletions.
Binary file modified bun.lockb
Binary file not shown.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@
"@trivago/prettier-plugin-sort-imports": "^3.4.0",
"@types/assert": "^1.5.6",
"@types/eslint": "^8.4.5",
"@types/jest-matchers": "^25.1.0",
"bun-types": "^0.1.5",
"jest-matchers": "^20.0.3",
"bun-types": "^0.5.8",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"typescript": "^5.0.0-dev.20221206"
"typescript": "latest"
}
}
9 changes: 4 additions & 5 deletions test/functions/Array.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import {
import { subtract } from '../../src/functions/Number'
import { exactly } from '../../src/functions/misc'
import { TupleOf } from '../../src/types/Array'
import { Throw, throwIfUndefined } from 'throw-expression'
import { ok as assert, deepStrictEqual } from 'assert'
import { describe, test } from 'bun:test'
import { Throw, throwIfUndefined } from 'throw-expression'

test('lengthGreaterOrEqual', () => {
const foo: string[] = []
Expand Down Expand Up @@ -163,8 +163,7 @@ describe('duplicate functions', () => {

test('duplicates', () => deepStrictEqual(findDuplicates([1, 1, 2, 3, 3, 3]), [1, 3]))

test('removeDuplicates', () =>
deepStrictEqual(removeDuplicates([1, 1, 2, 3, 3, 3]), [1, 2, 3]))
test('removeDuplicates', () => deepStrictEqual(removeDuplicates([1, 1, 2, 3, 3, 3]), [1, 2, 3]))
})

test('concat', () => {
Expand Down Expand Up @@ -251,13 +250,13 @@ describe('slice', () => {
exactly<[2, ...number[]]>()(slice([1, 2, 3] as [1, 2, ...number[]], 1))
})
test('start, rest start', () => {
exactly<[...number[], 1, 2]>()(slice([1, 2, 3] as [...number[], 1, 2], 1))
exactly<[...number[], 2, 3]>()(slice([1, 2, 3] as [...number[], 2, 3], 1))
})
test('end, rest end', () => {
exactly<number[]>()(slice([1, 2, 3] as [1, 2, ...number[]], 0, 1))
})
test('end, rest start', () => {
exactly<number[]>()(slice([1, 2, 3] as [...number[], 1, 2], 0, 1))
exactly<number[]>()(slice([1, 2, 3] as [...number[], 2, 3], 0, 1))
})
})
describe('not known at compiletime', () => {
Expand Down
18 changes: 13 additions & 5 deletions test/functions/misc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import {
} from '../../src/functions/misc'
import { NonNullish } from '../../src/types/misc'
import { ok as assert, throws } from 'assert'
import { describe, test } from 'bun:test'
import { expect as jestExpect } from 'expect'
import { describe, expect, test } from 'bun:test'

describe('exactly', () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment -- this test is for the any type
Expand Down Expand Up @@ -549,9 +548,18 @@ describe('runUntil', () => {
test('rejects', async () => {
let isDone = false
setTimeout(() => (isDone = true), 1000)
await jestExpect(
runUntil(() => new Promise<boolean>((res) => setTimeout(() => res(isDone), 10)), 100),
).rejects.toThrow("runUntil failed because the predicate didn't return true in 100 ms")
// TODO: update this when bun test has a thing for expect promise rejections
try {
await runUntil(
() => new Promise<boolean>((res) => setTimeout(() => res(isDone), 10)),
100,
)
throw new Error("didn't reject")
} catch (e) {
expect(String(e)).toContain(
"runUntil failed because the predicate didn't return true in 100 ms",
)
}
})
test('resolves', async () => {
let isDone = false
Expand Down
3 changes: 2 additions & 1 deletion test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../tsconfig.base.json",
"compilerOptions": {
"types": ["bun-types"],
"noEmit": true
"noEmit": true,
"skipLibCheck": true // https://github.com/oven-sh/bun/issues/2620
},
"include": ["**/*.ts"]
}
1 change: 1 addition & 0 deletions test/types/misc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
RequiredProperties,
RequiredRecursive,
} from '../../src/types/misc'
import { describe, test } from 'bun:test'

describe('OnlyInfer', () => {
test('basic', () => {
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"types": ["bun-types"],
"noEmit": true,
"allowJs": true,
"checkJs": true
Expand Down

0 comments on commit 26e1837

Please sign in to comment.