Skip to content

Commit 68322db

Browse files
Merge pull request #15 from wimpyprogrammer/hotfix/missing-types
Publish package with type definitions
2 parents 94b699a + 074a24c commit 68322db

File tree

12 files changed

+71
-49
lines changed

12 files changed

+71
-49
lines changed

.babelrc

Lines changed: 0 additions & 14 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- run: npm run lint
3636
- run: npm run build
3737
- run: npm run test
38-
- run: npx testpack-cli --keep={@babel/*,ts-jest,typescript} .babelrc tsconfig*.json src/e2e.spec.ts
38+
- run: npx testpack-cli --keep=@types/*,ts-jest,typescript jest.config.js tsconfig.json src/e2e.spec.ts src/tsconfig.test.json
3939

4040
- name: Upload test coverage report to Codecov
4141
uses: codecov/codecov-action@v1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
package-lock.json
2+
*.tsbuildinfo
23

34
coverage/
45
demo/lib/

.publishrc

Lines changed: 0 additions & 15 deletions
This file was deleted.

.release-it.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"hooks": {
3+
"before:init": ["npm run lint", "npm test"],
4+
"after:bump": "npm run build"
5+
},
6+
"git": {
7+
"changelog": false,
8+
"commit": false,
9+
"requireBranch": "main",
10+
"requireCommits": true,
11+
"tagName": "${version}"
12+
}
13+
}

demo/tsconfig.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
"es2015.core",
77
"es2015.iterable",
88
"es2016.array.include"
9-
]
9+
],
10+
"noEmit": true,
11+
"outDir": "./lib"
1012
},
1113
"extends": "../tsconfig.json",
12-
"include": ["src"],
14+
"include": ["src", "webpack.config.js"],
1315
"references": [{ "path": "../src" }]
1416
}

package.json

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
"type": "git",
66
"url": "git+https://github.com/wimpyprogrammer/regex-to-strings.git"
77
},
8+
"publishConfig": {
9+
"registry": "https://registry.npmjs.org/"
10+
},
811
"bugs": {
912
"url": "https://github.com/wimpyprogrammer/regex-to-strings/issues"
1013
},
@@ -15,7 +18,9 @@
1518
"main": "lib/index.js",
1619
"types": "./lib/index.d.ts",
1720
"files": [
18-
"lib/"
21+
"lib/**/*.js",
22+
"lib/**/*.js.map",
23+
"lib/**/*.d.ts"
1924
],
2025
"sideEffects": [
2126
"demo/**/polyfills.ts",
@@ -26,24 +31,15 @@
2631
},
2732
"scripts": {
2833
"build": "run-s build:*",
29-
"build:src": "babel src -d lib --extensions '.js,.ts' --ignore '**/*.spec.js','**/*.spec.ts' --delete-dir-on-start",
34+
"build:src": "tsc -b --clean && tsc -b",
3035
"build:demo": "wp --config demo/webpack.config.js",
31-
"build:types": "tsc --noEmit false --emitDeclarationOnly",
3236
"format": "prettier --write '{src,demo/src}/**'",
33-
"lint": "tsc -b && eslint . --report-unused-disable-directives",
37+
"lint": "tsc -b ./tsconfig.lint.json && eslint . --report-unused-disable-directives",
3438
"precommit": "pretty-quick --staged",
35-
"prepublish": "npx publish-please guard",
36-
"publish-please": "npx publish-please",
37-
"publish-please-prereqs": "npm run lint && npm run test && npm run build",
39+
"release": "npx release-it",
3840
"test": "jest --coverage"
3941
},
4042
"devDependencies": {
41-
"@babel/cli": "^7.13.10",
42-
"@babel/core": "^7.13.10",
43-
"@babel/plugin-proposal-class-properties": "^7.13.0",
44-
"@babel/preset-env": "^7.13.10",
45-
"@babel/preset-typescript": "^7.13.0",
46-
"@types/escape-string-regexp": "^2.0.1",
4743
"@types/history": "^4.7.3",
4844
"@types/jest": "^26.0.10",
4945
"@types/jest-when": "^2.4.1",

src/e2e.spec.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { count, expand, expandAll, expandN } from '.';
22

33
describe('count end-to-end', () => {
4+
it('includes typings', () => {
5+
expect(() => {
6+
// @ts-expect-error Accepts string | RegExp
7+
count(123);
8+
}).toThrow();
9+
});
10+
411
it('returns a count of potential strings that match pattern', () => {
512
const numStrings = count(/[a-z]{5}/i);
613

@@ -11,6 +18,13 @@ describe('count end-to-end', () => {
1118
describe('expand end-to-end', () => {
1219
const phoneNumberPattern = /((\(555\) ?)|(555-))?\d{3}-\d{4}/;
1320

21+
it('includes typings', () => {
22+
expect(() => {
23+
// @ts-expect-error Accepts string | RegExp
24+
expand(123);
25+
}).toThrow();
26+
});
27+
1428
it('returns a count of potential strings that match pattern', () => {
1529
const phoneNumberExpander = expand(phoneNumberPattern);
1630

@@ -29,6 +43,13 @@ describe('expand end-to-end', () => {
2943
});
3044

3145
describe('expandAll end-to-end', () => {
46+
it('includes typings', () => {
47+
expect(() => {
48+
// @ts-expect-error Accepts string | RegExp
49+
expandAll(123);
50+
}).toThrow();
51+
});
52+
3253
it('returns all strings that match pattern', () => {
3354
const strings = expandAll(/\d/);
3455

@@ -40,6 +61,13 @@ describe('expandAll end-to-end', () => {
4061
});
4162

4263
describe('expandN end-to-end', () => {
64+
it('includes typings', () => {
65+
expect(() => {
66+
// @ts-expect-error Accepts string | RegExp
67+
expandN(123, 10);
68+
}).toThrow();
69+
});
70+
4371
it('returns no more than N strings that match pattern', () => {
4472
const pattern = /\d{3,5}/;
4573
const strings = expandN(pattern, 5);

src/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"compilerOptions": {
3-
"lib": ["es5", "es2015.core", "es2015.iterable", "es2016.array.include"]
3+
"lib": ["es5", "es2015.core", "es2015.iterable", "es2016.array.include"],
4+
"outDir": "../lib",
5+
"rootDir": "./"
46
},
57
"extends": "../tsconfig.json",
68
"exclude": ["../**/*.spec.ts", "../**/*.config.js"],

src/tsconfig.test.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
"es2016.array.include",
88
"es2017.string"
99
],
10+
"noEmit": true,
11+
"outDir": "../lib",
1012
"types": ["jest", "regexp-tree", "./types/regexp-tree"]
1113
},
1214
"extends": "../tsconfig.json",
13-
"include": ["./**/*.spec.ts", "../**/*.config.js"],
15+
"include": ["./**/*.spec.ts", "../jest.config.js"],
1416
"references": [{ "path": "./" }]
1517
}

0 commit comments

Comments
 (0)