Skip to content

Commit

Permalink
Update typescript
Browse files Browse the repository at this point in the history
Closes GH-216.

Reviewed-by: Remco Haszing <remcohaszing@gmail.com>
Reviewed-by: Titus Wormer <tituswormer@gmail.com>
  • Loading branch information
ChristianMurphy committed Aug 9, 2023
1 parent b35afe0 commit ffc146c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -63,7 +63,7 @@
"remark-preset-wooorm": "^9.0.0",
"tsd": "^0.24.0",
"type-coverage": "^2.0.0",
"typescript": "^4.0.0",
"typescript": "^5.0.0",
"xo": "^0.54.0"
},
"scripts": {
Expand Down
8 changes: 8 additions & 0 deletions test/process.js
Expand Up @@ -47,6 +47,10 @@ test('process(file, done)', () => {
})
.use(
() =>
/**
* @param {Node} tree
* @param {VFile} file
*/
function (tree, file) {
assert.equal(tree, givenNode, 'should pass `tree` to transformers')
assert.equal(file, givenFile, 'should pass `file` to transformers')
Expand Down Expand Up @@ -100,6 +104,10 @@ test('process(file)', () => {
})
.use(
() =>
/**
* @param {Node} tree
* @param {VFile} file
*/
function (tree, file) {
assert.equal(tree, givenNode, 'should pass `tree` to transformers')
assert.equal(file, givenFile, 'should pass `file` to transformers')
Expand Down
12 changes: 12 additions & 0 deletions test/run.js
@@ -1,3 +1,7 @@
/**
* @typedef {import('unist').Node} Node
*/

import process from 'node:process'
import assert from 'node:assert/strict'
import test from 'node:test'
Expand Down Expand Up @@ -549,6 +553,10 @@ test('runSync(node[, file])', async () => {
unified()
.use(
() =>
/**
* @param {Node} tree
* @param {VFile} file
*/
function (tree, file) {
assert.equal(tree, givenNode, 'passes given tree to transformers')
assert.equal(file, givenFile, 'passes given file to transformers')
Expand All @@ -559,6 +567,10 @@ test('runSync(node[, file])', async () => {
unified()
.use(
() =>
/**
* @param {Node} _
* @param {VFile} file
*/
function (_, file) {
assert.equal(
file.toString(),
Expand Down
28 changes: 20 additions & 8 deletions test/use.js
@@ -1,3 +1,8 @@
/**
* @typedef {import('unist').Node} Node
* @typedef {import('vfile').VFile} VFile
*/

import assert from 'node:assert/strict'
import test from 'node:test'
import {unified} from '../index.js'
Expand Down Expand Up @@ -252,14 +257,21 @@ test('use(plugin[, options])', async (t) => {
const condition = true

processor
.use(() => (node, file) => {
assert.equal(node, givenNode, 'should attach a transformer (#1)')
assert.ok('message' in file, 'should attach a transformer (#2)')

if (condition) {
throw new Error('Alpha bravo charlie')
}
})
.use(
() =>
/**
* @param {Node} node
* @param {VFile} file
*/
function (node, file) {
assert.equal(node, givenNode, 'should attach a transformer (#1)')
assert.ok('message' in file, 'should attach a transformer (#2)')

if (condition) {
throw new Error('Alpha bravo charlie')
}
}
)
.freeze()

assert.throws(
Expand Down
3 changes: 0 additions & 3 deletions tsconfig.json
Expand Up @@ -6,11 +6,8 @@
"declaration": true,
"emitDeclarationOnly": true,
"exactOptionalPropertyTypes": true,
"forceConsistentCasingInFileNames": true,
"lib": ["es2020"],
"module": "node16",
"newLine": "lf",
"skipLibCheck": true,
"strict": true,
"target": "es2020"
}
Expand Down

0 comments on commit ffc146c

Please sign in to comment.