From a3b3bad365bb1933ee9700e74e7d61625ae3fb09 Mon Sep 17 00:00:00 2001 From: Misha Kaletsky Date: Sat, 29 Jan 2022 15:57:48 -0500 Subject: [PATCH] Switch to expect-type See https://github.com/sindresorhus/dot-prop/issues/84 and https://github.com/SamVerschueren/tsd/issues/142 --- index.test-d.ts | 20 ++++++++++---------- package.json | 7 ++++--- tsconfig.json | 8 ++++++++ 3 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 tsconfig.json diff --git a/index.test-d.ts b/index.test-d.ts index d33e872..1462f06 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -1,18 +1,18 @@ -import {expectType, expectAssignable} from 'tsd'; +import {expectTypeOf} from 'expect-type'; import {getProperty, setProperty, hasProperty, deleteProperty} from './index.js'; -expectType(getProperty({foo: {bar: 'unicorn'}}, 'foo.bar')); -expectType(getProperty({foo: {bar: 'a'}}, 'foo.notDefined.deep')); -expectAssignable( +expectTypeOf(getProperty({foo: {bar: 'unicorn'}}, 'foo.bar')).toBeString(); +expectTypeOf(getProperty({foo: {bar: 'a'}}, 'foo.notDefined.deep')).toBeUndefined(); +expectTypeOf( getProperty({foo: {bar: 'a'}}, 'foo.notDefined.deep', 'default value'), -); -expectType( +).toBeString(); +expectTypeOf( getProperty({foo: {'dot.dot': 'unicorn'}}, 'foo.dot\\.dot'), -); +).toEqualTypeOf(); const object = {foo: {bar: 'a'}}; -expectType(setProperty(object, 'foo.bar', 'b')); +expectTypeOf(setProperty(object, 'foo.bar', 'b')).toEqualTypeOf(object); -expectType(hasProperty({foo: {bar: 'unicorn'}}, 'foo.bar')); +expectTypeOf(hasProperty({foo: {bar: 'unicorn'}}, 'foo.bar')).toEqualTypeOf(); -expectType(deleteProperty({foo: {bar: 'a'}}, 'foo.bar')); +expectTypeOf(deleteProperty({foo: {bar: 'a'}}, 'foo.bar')).toEqualTypeOf(); diff --git a/package.json b/package.json index 697cc4b..350a4dc 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "node": "^12.20.0 || ^14.13.1 || >=16.0.0" }, "scripts": { - "test": "xo && ava && tsd", + "test": "xo && ava && tsc", "bench": "node benchmark.js" }, "files": [ @@ -42,7 +42,8 @@ "devDependencies": { "ava": "^4.0.1", "benchmark": "^2.1.4", - "tsd": "^0.19.1", + "expect-type": "^0.13.0", + "typescript": "^4.5.5", "xo": "^0.47.0" } -} +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..d1edbb2 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "lib": ["es2020"], + "strict": true, + "noEmit": true + }, + "include": ["*.ts"] +}