diff --git a/.circleci/config.yml b/.circleci/config.yml index 28280c6..74caed0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -123,10 +123,10 @@ commands: command: npm pack - run: name: Setup Import Test - command: echo $PWD && cd .. && mkdir test-import && cp -a project/test-import/ test-import/test-import/ && cd test-import && npm init -y && npm i ../project/is-promise-2.2.2.tgz + command: echo $PWD && cd .. && cp -a project/test-import/ test-import/ && cd test-import && npm i && npm i ../project/is-promise-2.2.2.tgz - run: name: Test Import - command: cd ../test-import && node test-import/test.js + command: cd ../test-import && npm test publish-dry-run: steps: diff --git a/package.json b/package.json index c8a6680..eb3551f 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ }, "files": [ "index.js", - "index.mjs" + "index.mjs", + "index.d.ts" ], "repository": { "type": "git", diff --git a/test-import/index.ts b/test-import/index.ts new file mode 100644 index 0000000..2ef2089 --- /dev/null +++ b/test-import/index.ts @@ -0,0 +1,9 @@ +import * as ta from 'type-assertions'; +import isPromise from 'is-promise'; + +declare const x: number | Promise; +if (isPromise(x)) { + ta.assert>>(); +} else { + ta.assert>(); +} \ No newline at end of file diff --git a/test-import/package.json b/test-import/package.json new file mode 100644 index 0000000..7090b05 --- /dev/null +++ b/test-import/package.json @@ -0,0 +1,11 @@ +{ + "name": "is-promise-test-import", + "private": true, + "@rollingversions/ignore": true, + "scripts": { + "test": "node test" + }, + "dependencies": { + "type-assertions": "^1.1.0" + } +} diff --git a/test-import/test.js b/test-import/test.js index 50ef5e6..9d0ef7f 100644 --- a/test-import/test.js +++ b/test-import/test.js @@ -31,5 +31,11 @@ console.log('CommonJS tests passed') if(parseInt(process.version.split('.')[0].substr(1), 10) >= 14) { const result = require('child_process').spawnSync('node', ['test.mjs'], {cwd: __dirname, stdio: 'inherit'}); - process.exit(result.status); + if (result.status) process.exit(result.status); +} + +if(parseInt(process.version.split('.')[0].substr(1), 10) >= 12) { + const result = require('child_process').spawnSync('npx', ['typescript', 'index.ts'], {cwd: __dirname, stdio: 'inherit'}); + if (result.status) process.exit(result.status); + console.log('TypeScript tests passed'); } \ No newline at end of file diff --git a/test-import/tsconfig.json b/test-import/tsconfig.json new file mode 100644 index 0000000..8bf3bdd --- /dev/null +++ b/test-import/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "noImplicitAny": true, + "skipLibCheck": false, + "strict": true + } +} \ No newline at end of file