From 9683cd7fd95bb471ec6f7f8076f981fdbc79509f Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Mon, 4 Feb 2019 02:37:14 +0700 Subject: [PATCH] Run TS as a require hook for tests instead of precompile --- package.json | 27 +++++++++++++++++++-------- {source/tests => test}/test.ts | 4 ++-- tsconfig.json | 5 ++++- 3 files changed, 25 insertions(+), 11 deletions(-) rename {source/tests => test}/test.ts (99%) diff --git a/package.json b/package.json index bf0d9fe..ce688bb 100644 --- a/package.json +++ b/package.json @@ -9,15 +9,15 @@ "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, - "main": "dist/index.js", + "main": "dist", "engines": { "node": ">=6" }, "scripts": { "lint": "tslint --format stylish --project .", "build": "del dist && tsc", - "test": "npm run lint && npm run build && ava dist/tests", - "prepublish": "npm run build && del dist/tests" + "test": "npm run lint && ava", + "prepublishOnly": "npm run build" }, "files": [ "dist" @@ -46,18 +46,29 @@ "devDependencies": { "@sindresorhus/tsconfig": "^0.1.0", "@types/jsdom": "^11.12.0", - "@types/node": "^10.12.10", + "@types/node": "^10.12.21", "@types/tempy": "^0.2.0", "@types/zen-observable": "^0.8.0", - "ava": "^0.25.0", + "ava": "^1.2.0", "del-cli": "^1.1.0", "jsdom": "^11.6.2", - "rxjs": "^6.3.3", + "rxjs": "^6.4.0", "tempy": "^0.2.1", + "ts-node": "^8.0.2", "tslint": "^5.9.1", "tslint-xo": "^0.10.0", - "typescript": "^3.2.1", + "typescript": "^3.3.1", "zen-observable": "^0.8.8" }, - "types": "dist/index.d.ts" + "types": "dist", + "ava": { + "babel": false, + "compileEnhancements": false, + "extensions": [ + "ts" + ], + "require": [ + "ts-node/register" + ] + } } diff --git a/source/tests/test.ts b/test/test.ts similarity index 99% rename from source/tests/test.ts rename to test/test.ts index 8342b54..4dbf999 100644 --- a/source/tests/test.ts +++ b/test/test.ts @@ -4,7 +4,7 @@ import Stream from 'stream'; import util from 'util'; import tempy from 'tempy'; import {URL} from 'url'; -import test, {TestContext, Context} from 'ava'; +import test, {ExecutionContext} from 'ava'; import {JSDOM} from 'jsdom'; import {Subject, Observable} from 'rxjs'; import ZenObservable from 'zen-observable'; @@ -377,7 +377,7 @@ const types = new Map([ ]); // This ensures a certain method matches only the types it's supposed to and none of the other methods' types -const testType = (t: TestContext & Context, type: string, exclude?: string[]) => { +const testType = (t: ExecutionContext, type: string, exclude?: string[]) => { const testData = types.get(type); if (testData === undefined) { diff --git a/tsconfig.json b/tsconfig.json index 5f5c71e..058d3a0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,5 +9,8 @@ "esnext.asynciterable", "dom" ] - } + }, + "include": [ + "source" + ] }