Skip to content

Commit 9dc0e7a

Browse files
committed
Update tsconfig.json
1 parent 3cb902f commit 9dc0e7a

File tree

4 files changed

+26
-23
lines changed

4 files changed

+26
-23
lines changed

index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ export function parents(node) {
3535
* Proxy of `node`.
3636
*/
3737
function wrapNode(node, parent) {
38-
if (cache.has(node)) {
39-
return cache.get(node)
38+
const entry = cache.get(node)
39+
40+
if (entry) {
41+
return entry
4042
}
4143

4244
/** @type {Proxy} */
@@ -46,6 +48,7 @@ function wrapNode(node, parent) {
4648

4749
for (key in node) {
4850
if (key !== 'children') {
51+
// @ts-expect-error: indexable.
4952
proxy[key] = node[key]
5053
}
5154
}

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,25 @@
3939
"@types/unist": "^2.0.0"
4040
},
4141
"devDependencies": {
42-
"@types/clone": "^2.1.1",
42+
"@types/clone": "^2.0.0",
43+
"@types/mdast": "^3.0.0",
4344
"@types/tape": "^4.0.0",
4445
"c8": "^7.0.0",
4546
"clone": "^2.0.0",
4647
"prettier": "^2.0.0",
4748
"remark-cli": "^11.0.0",
4849
"remark-preset-wooorm": "^9.0.0",
49-
"rimraf": "^3.0.0",
5050
"tape": "^5.0.0",
5151
"type-coverage": "^2.0.0",
5252
"typescript": "^4.0.0",
5353
"xo": "^0.53.0"
5454
},
5555
"scripts": {
5656
"prepack": "npm run build && npm run format",
57-
"build": "rimraf \"*.d.ts\" && tsc && type-coverage",
57+
"build": "tsc --build --clean && tsc --build && type-coverage",
5858
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
59-
"test-api": "node test.js",
60-
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
59+
"test-api": "node --conditions development test.js",
60+
"test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api",
6161
"test": "npm run build && npm run format && npm run test-coverage"
6262
},
6363
"prettier": {
@@ -76,7 +76,7 @@
7676
},
7777
"remarkConfig": {
7878
"plugins": [
79-
"preset-wooorm"
79+
"remark-preset-wooorm"
8080
]
8181
},
8282
"typeCoverage": {

test.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
/**
2-
* @typedef {import('unist').Node} Node
2+
* @typedef {import('mdast').Root} Root
33
* @typedef {import('unist').Parent} Parent
44
*/
55

66
import test from 'tape'
7+
// To do: replace with `structuredClone` when stable.
78
import clone from 'clone'
89
import {parents} from './index.js'
910

11+
/** @type {Root} */
1012
const ast = {
1113
type: 'root',
1214
children: [
@@ -29,12 +31,8 @@ test('immutable', function (t) {
2931
t.deepEqual(ast, original, 'original AST is unchanged')
3032
t.notEqual(root, ast, 'returns a different object')
3133
t.deepEqual(root, ast, 'structurally equivalent')
32-
t.equal(
33-
// type-coverage:ignore-next-line, yeah, that’s expected.
34-
ast.children[0].parent,
35-
undefined,
36-
'original AST does not obtain parent links'
37-
)
34+
const head = ast.children[0]
35+
t.ok(!('parent' in head), 'original AST does not obtain parent links')
3836
t.end()
3937
})
4038

tsconfig.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
{
2-
"include": ["*.js"],
2+
"include": ["**/*.js"],
3+
"exclude": ["coverage/", "node_modules/"],
34
"compilerOptions": {
4-
"target": "ES2020",
5-
"lib": ["ES2020"],
6-
"module": "ES2020",
7-
"moduleResolution": "node",
8-
"allowJs": true,
95
"checkJs": true,
106
"declaration": true,
117
"emitDeclarationOnly": true,
12-
"allowSyntheticDefaultImports": true,
13-
"skipLibCheck": true
8+
"exactOptionalPropertyTypes": true,
9+
"forceConsistentCasingInFileNames": true,
10+
"lib": ["es2020"],
11+
"module": "node16",
12+
"newLine": "lf",
13+
"skipLibCheck": true,
14+
"strict": true,
15+
"target": "es2020"
1416
}
1517
}

0 commit comments

Comments
 (0)