Skip to content

Commit

Permalink
fix: Update utils for the latest TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
hangxingliu committed Nov 19, 2023
1 parent b238132 commit 191586c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"build:web-ext": "webpack --mode production --devtool hidden-source-map",
"build:utils": "tsc -p tsconfig.utils.json",
"build:syntax": "ts-node --project tsconfig.syntax.json ./src/syntax/generate-tmLanguage.ts",
"clean": "rimraf 'src/extension/**/*.js' 'src/utils/**/*.js'"
"clean": "rimraf '.tsc' 'src/extension/**/*.js' 'src/utils/**/*.js'"
},
"extensionKind": [
"ui",
Expand Down
8 changes: 4 additions & 4 deletions src/utils/download_lua_hint_data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

import type { CheerioAPI, Node } from "cheerio";
import type { AnyNode, BasicAcceptedElems, CheerioAPI } from "cheerio";

import { nginxLuaDocsBaseURL, luaRestyDocsURLs, manifestFiles, ManifestItemType, detailsFile, luaSnippetFile, nginxLuaModuleURLs } from "./config";
import { getText, loadHtml, print, initHttpCache, JsonFileWriter, writeJSON } from "./helper";
Expand Down Expand Up @@ -85,7 +85,7 @@ async function main() {

function processDirectiveElement(
$: CheerioAPI,
ele: Node,
ele: BasicAcceptedElems<AnyNode>,
baseUrl: string,
modIndex: number,
detailsStream: JsonFileWriter,
Expand Down Expand Up @@ -183,7 +183,7 @@ function processDirectiveElement(
return true;
}

function processSnippetElement($: CheerioAPI, ele: Node) {
function processSnippetElement($: CheerioAPI, ele: BasicAcceptedElems<AnyNode>) {
const name = $(ele).text();
const directive = $("#user-content-" + name.toLocaleLowerCase().replace(/[\.:]/g, ""));
if (name == 'Introduction' || directive.length == 0) return;
Expand Down Expand Up @@ -242,7 +242,7 @@ async function processRestyREADME(baseUrl: string, prefix: string) {
processRestySnippetElement($, ele, baseUrl, prefix);
});
}
function processRestySnippetElement($: CheerioAPI, ele: Node, baseUrl: string, prefix: string) {
function processRestySnippetElement($: CheerioAPI, ele: BasicAcceptedElems<AnyNode>, baseUrl: string, prefix: string) {
if ($(ele).attr('href') !== '#methods') return;

const directiveLists = $(ele).next("ul").find("li a");
Expand Down
14 changes: 14 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"outDir": ".tsc",
"module": "CommonJS",
"declaration": false,
"removeComments": false,
"target": "ES2022",
"sourceMap": true,
"skipLibCheck": true,
"strictNullChecks": false
},
"include": ["src"],
"exclude": [".tsc", "node_modules"]
}
4 changes: 2 additions & 2 deletions tsconfig.utils.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"compilerOptions": {
"module": "commonjs",
"module": "CommonJS",
"declaration": false,
"removeComments": false,
"target": "ES2020",
"target": "ES2022",
"sourceMap": false,
"skipLibCheck": true
},
Expand Down

0 comments on commit 191586c

Please sign in to comment.