Skip to content

Commit 28ca922

Browse files
committed
feature: @putout/operator-parens: types
1 parent 1a66c46 commit 28ca922

8 files changed

Lines changed: 36 additions & 2 deletions

File tree

packages/operator-parens/.madrun.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import {run} from 'madrun';
22

33
export default {
4-
'wisdom': () => run(['lint', 'coverage']),
4+
'wisdom': () => run(['lint', 'coverage', 'test:dts']),
55
'test': () => `tape 'test/*.js' 'lib/**/*.spec.js'`,
6+
'test:dts': () => 'check-dts test/*.ts',
67
'watch:test': async () => `nodemon -w lib -x "${await run('test')}"`,
78
'lint': () => 'putout .',
89
'fresh:lint': () => run('lint', '--fresh'),

packages/operator-parens/.nycrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"exclude": [
55
"**/*.spec.*",
66
"**/*.config.*",
7+
"**/*.ts",
78
"**/fixture",
89
".*.*",
910
"test"

packages/operator-parens/.putout.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
2-
"printer": "putout",
2+
"rules": {
3+
"madrun/add-test-dts": "on",
4+
"coverage/add-to-exclude": ["on", {
5+
"list": ["**/*.ts"]
6+
}]
7+
},
38
"match": {
49
"*.md": {
510
"declare": "off",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import {NodePath} from '@putout/babel';
2+
3+
export function addParens(path: NodePath): NodePath;
4+
export function removeParens(path: NodePath): NodePath;
5+
export function hasParens(path: NodePath, printer?: string): boolean;

packages/operator-parens/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
"url": "git+https://github.com/coderaiser/putout.git"
1515
},
1616
"scripts": {
17+
"wisdom": "madrun wisdom",
1718
"test": "madrun test",
19+
"test:dts": "madrun test:dts",
1820
"watch:test": "madrun watch:test",
1921
"lint": "madrun lint",
2022
"fresh:lint": "madrun fresh:lint",
@@ -30,6 +32,7 @@
3032
"parens"
3133
],
3234
"devDependencies": {
35+
"check-dts": "^1.0.0",
3336
"eslint": "^10.0.0",
3437
"eslint-plugin-putout": "^31.0.0",
3538
"madrun": "^13.0.0",
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {
2+
addParens,
3+
removeParens,
4+
hasParens,
5+
} from '../lib/parens.js';
6+
7+
// THROWS Argument of type 'number' is not assignable to parameter of type 'NodePath_Final'.
8+
addParens(5);
9+
10+
// THROWS Argument of type 'number' is not assignable to parameter of type 'NodePath_Final'.
11+
removeParens(5);
12+
13+
// THROWS Expected 1-2 arguments, but got 0.
14+
hasParens();

packages/putout/test/operator.errors.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const {
1313
matchFiles,
1414
findFileUp,
1515
isSimpleRegExp,
16+
addParens,
1617
} = operator;
1718

1819
// THROWS Expected 2 arguments, but got 1.
@@ -56,3 +57,6 @@ isSimpleRegExp(5);
5657

5758
// THROWS Expected 1 arguments, but got 0
5859
isSimpleRegExp();
60+
61+
// THROWS Argument of type 'number' is not assignable to parameter of type 'NodePath'
62+
addParens(5);

packages/putout/types/operator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export * from '@putout/operator-ignore';
99
export * from '@putout/operator-add-args';
1010
export * from '@putout/operator-filesystem';
1111
export * from '@putout/operator-match-files';
12+
export * from '@putout/operator-parens';
1213
export * from '@putout/operator-regexp';
1314
export * from '@putout/operator-find-file-up';
1415

0 commit comments

Comments
 (0)