From 91541b9062905f08a310151da51be6cc3d68d206 Mon Sep 17 00:00:00 2001 From: Christian Murphy Date: Fri, 17 Mar 2023 08:45:55 -0700 Subject: [PATCH 1/3] TypeScript 5 --- package.json | 2 +- test/process.js | 8 ++++++++ test/run.js | 12 ++++++++++++ test/use.js | 28 ++++++++++++++++++++-------- tsconfig.json | 1 - 5 files changed, 41 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index d336e29b..63eeecbd 100644 --- a/package.json +++ b/package.json @@ -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.53.0" }, "scripts": { diff --git a/test/process.js b/test/process.js index af61ef2f..cdf485e6 100644 --- a/test/process.js +++ b/test/process.js @@ -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') @@ -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') diff --git a/test/run.js b/test/run.js index 45f0284d..2a1568a1 100644 --- a/test/run.js +++ b/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' @@ -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') @@ -559,6 +567,10 @@ test('runSync(node[, file])', async () => { unified() .use( () => + /** + * @param {Node} _ + * @param {VFile} file + */ function (_, file) { assert.equal( file.toString(), diff --git a/test/use.js b/test/use.js index e3fa5913..ea01b1b6 100644 --- a/test/use.js +++ b/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' @@ -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( diff --git a/tsconfig.json b/tsconfig.json index 38a7e9be..1d222876 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,6 @@ "lib": ["es2020"], "module": "node16", "newLine": "lf", - "skipLibCheck": true, "strict": true, "target": "es2020" } From 521787d118832b7f6a58e84f002dbe173f5c87ab Mon Sep 17 00:00:00 2001 From: Christian Murphy Date: Fri, 17 Mar 2023 08:57:20 -0700 Subject: [PATCH 2/3] types remove lf option, it is default in ts5 --- tsconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 1d222876..35dd9616 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,6 @@ "forceConsistentCasingInFileNames": true, "lib": ["es2020"], "module": "node16", - "newLine": "lf", "strict": true, "target": "es2020" } From f430744b449718019f601168d4fee9d838525c72 Mon Sep 17 00:00:00 2001 From: Christian Murphy Date: Fri, 17 Mar 2023 08:59:15 -0700 Subject: [PATCH 3/3] types enforce casing is now default enabled --- tsconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 35dd9616..80ce6dd3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,6 @@ "declaration": true, "emitDeclarationOnly": true, "exactOptionalPropertyTypes": true, - "forceConsistentCasingInFileNames": true, "lib": ["es2020"], "module": "node16", "strict": true,