From 22cdf1c4ad9670be0013004f44f6a45a6df62796 Mon Sep 17 00:00:00 2001 From: Mark Lundin Date: Thu, 26 Sep 2024 11:51:13 +0100 Subject: [PATCH 1/4] 1.2.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3eee914..c843ffd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@playcanvas/attribute-parser", - "version": "1.1.0", + "version": "1.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@playcanvas/attribute-parser", - "version": "1.1.0", + "version": "1.2.0", "dependencies": { "@microsoft/tsdoc": "^0.15.0", "@playcanvas/eslint-config": "^1.7.4", diff --git a/package.json b/package.json index 1789894..a3715de 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "engines": { "node": ">=18.0.0" }, - "version": "1.1.0", + "version": "1.2.0", "dependencies": { "@microsoft/tsdoc": "^0.15.0", "@playcanvas/eslint-config": "^1.7.4", From 3d9f5321a6f0b86cc9f799a7bd6b6e3943cf0b57 Mon Sep 17 00:00:00 2001 From: Mark Lundin Date: Fri, 4 Oct 2024 12:59:02 +0100 Subject: [PATCH 2/4] Update compiler options and JSDocParser initialization --- src/index.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index f8a1429..a151709 100644 --- a/src/index.js +++ b/src/index.js @@ -8,9 +8,10 @@ import { createDefaultMapFromCDN, flatMapAnyNodes, getExportedNodes, getType, in const toLowerCamelCase = str => str[0].toLowerCase() + str.substring(1); const COMPILER_OPTIONS = { + noLib: true, strict: false, skipLibCheck: true, // Skip type checking of declaration files - target: ts.ScriptTarget.ES2022, // If this version changes, the types must be updated in the /rollup.config.mjs + target: ts.ScriptTarget.ES2023, // If this version changes, the types must be updated in the /rollup.config.mjs module: ts.ModuleKind.CommonJS, checkJs: true, // Enable JSDoc parsing allowJs: true, @@ -39,16 +40,18 @@ export class JSDocParser { * @param {string} libPath - The path to standard library files * @returns {Promise} - The initialized JSDocParser */ - async init(libPath = '') { + async init(libPath) { if (this._env) { return this; } let fsMap; - if (libPath) { - fsMap = await createDefaultMapFromCDN({ target: ts.ScriptTarget.ES2022 }, libPath, ts); - } else { + // This is a node only option. If no lib path is passed, attempt to resolve ES types from node_modules. + if (!libPath) { fsMap = await createDefaultMapFromNodeModules(COMPILER_OPTIONS, ts); + } else { + const types = await fetch(libPath).then(r => r.text()); + fsMap = new Map([['/lib.d.ts', types]]); } // Set up the virtual file system and environment From 9acbcbf386a6055b8c5a685dcdbef2bcee3dff30 Mon Sep 17 00:00:00 2001 From: Mark Lundin Date: Fri, 4 Oct 2024 13:08:46 +0100 Subject: [PATCH 3/4] Update JSDocParser init() method to handle different types of library paths --- src/index.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index a151709..430861c 100644 --- a/src/index.js +++ b/src/index.js @@ -37,7 +37,7 @@ export class JSDocParser { /** * Initializes the JSDocParser with the standard library files * - * @param {string} libPath - The path to standard library files + * @param {string} libPath - A path to a directory of library types, or a path to the '.d.ts' file itself * @returns {Promise} - The initialized JSDocParser */ async init(libPath) { @@ -46,12 +46,21 @@ export class JSDocParser { } let fsMap; - // This is a node only option. If no lib path is passed, attempt to resolve ES types from node_modules. if (!libPath) { + + // This is a node only option. If no lib path is passed, attempt to resolve ES types from node_modules. fsMap = await createDefaultMapFromNodeModules(COMPILER_OPTIONS, ts); - } else { + + } else if(libPath.endsWith('.d.ts')) { + + // If the libPath is a '.d.ts' file then load it and add it const types = await fetch(libPath).then(r => r.text()); fsMap = new Map([['/lib.d.ts', types]]); + + } else { + + // A libPath was supplied, but not to a '.d.ts', so assume this is a path to types + fsMap = await createDefaultMapFromCDN(COMPILER_OPTIONS, libPath, ts); } // Set up the virtual file system and environment From 1c2a5d5be0576f3162167c46787ee9f0aded8fb8 Mon Sep 17 00:00:00 2001 From: Mark Lundin Date: Fri, 4 Oct 2024 13:14:21 +0100 Subject: [PATCH 4/4] lint --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 430861c..1d2cf2a 100644 --- a/src/index.js +++ b/src/index.js @@ -51,7 +51,7 @@ export class JSDocParser { // This is a node only option. If no lib path is passed, attempt to resolve ES types from node_modules. fsMap = await createDefaultMapFromNodeModules(COMPILER_OPTIONS, ts); - } else if(libPath.endsWith('.d.ts')) { + } else if (libPath.endsWith('.d.ts')) { // If the libPath is a '.d.ts' file then load it and add it const types = await fetch(libPath).then(r => r.text());