detype 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -83,10 +83,6 @@ If you just want to remove the magic comments, you can use the `-m` CLI flag or
83
83
  console.log("Hello from TypeScript");
84
84
  ```
85
85
 
86
- ## System requirements
87
-
88
- `detype` requires Node version 14.19.3 or later.
89
-
90
86
  ## CLI Usage
91
87
 
92
88
  ```
package/dist/cli.js CHANGED
@@ -125,8 +125,7 @@ async function removeTypes(code, fileName, options) {
125
125
  code = processMagicComments(code);
126
126
  const removeComments = {
127
127
  enter(p) {
128
- if (!p.node.leadingComments)
129
- return;
128
+ if (!p.node.leadingComments) return;
130
129
  for (let i = p.node.leadingComments.length - 1; i >= 0; i--) {
131
130
  const comment = p.node.leadingComments[i];
132
131
  if (code.slice(comment.end).match(/^\s*\n\s*\n/) || comment.value.includes("@detype: empty-line")) {
@@ -171,8 +170,7 @@ async function removeTypes(code, fileName, options) {
171
170
  );
172
171
  }
173
172
  async function removeTypesFromVueSfcScript(code, fileName, script, templateAst, options) {
174
- if (script === null || script.lang !== "ts")
175
- return code;
173
+ if (script === null || script.lang !== "ts") return code;
176
174
  if (script.setup && templateAst) {
177
175
  const expressions = /* @__PURE__ */ new Set();
178
176
  (0, import_template_ast_types.traverse)(templateAst, {
@@ -210,12 +208,10 @@ function processMagicComments(input) {
210
208
  let start = input.indexOf(REPLACE_COMMENT);
211
209
  while (start >= 0) {
212
210
  const middle = input.indexOf(WITH_COMMENT, start);
213
- if (middle < 0)
214
- return input;
211
+ if (middle < 0) return input;
215
212
  const middleEnd = middle + WITH_COMMENT.length;
216
213
  const end = input.indexOf(END_COMMENT, middleEnd);
217
- if (end < 0)
218
- return input;
214
+ if (end < 0) return input;
219
215
  const endEnd = end + END_COMMENT.length;
220
216
  const before = input.slice(0, start);
221
217
  const newText = input.slice(middleEnd, end).replaceAll(/^\s*\/\//gm, "");
@@ -233,12 +229,10 @@ async function removeMagicComments(code, fileName, prettierOptions) {
233
229
  let startEnd = start + REPLACE_COMMENT.length;
234
230
  while (start >= 0) {
235
231
  const middle = code.indexOf(WITH_COMMENT, start);
236
- if (middle < 0)
237
- return code;
232
+ if (middle < 0) return code;
238
233
  const middleEnd = middle + WITH_COMMENT.length;
239
234
  const end = code.indexOf(END_COMMENT, middleEnd);
240
- if (end < 0)
241
- return code;
235
+ if (end < 0) return code;
242
236
  const endEnd = end + END_COMMENT.length;
243
237
  const before = code.slice(0, start);
244
238
  const keptText = code.slice(startEnd, middle);
@@ -279,7 +273,7 @@ var import_fast_glob = __toESM(require("fast-glob"));
279
273
  // package.json
280
274
  var package_default = {
281
275
  name: "detype",
282
- version: "1.0.6",
276
+ version: "1.0.8",
283
277
  description: "Removes TypeScript type annotations but keeps the formatting",
284
278
  main: "dist/index.js",
285
279
  bin: "detype.js",
@@ -300,27 +294,27 @@ var package_default = {
300
294
  "index.d.ts"
301
295
  ],
302
296
  dependencies: {
303
- "@babel/core": "^7.24.3",
304
- "@babel/preset-typescript": "^7.24.1",
305
- "@vue/compiler-dom": "^3.4.21",
306
- "@vue/compiler-sfc": "^3.4.21",
297
+ "@babel/core": "^7.24.7",
298
+ "@babel/preset-typescript": "^7.24.7",
299
+ "@vue/compiler-dom": "^3.4.27",
300
+ "@vue/compiler-sfc": "^3.4.27",
307
301
  "@vuedx/compiler-sfc": "0.7.1",
308
302
  "@vuedx/template-ast-types": "0.7.1",
309
303
  "fast-glob": "^3.3.2",
310
- prettier: "^3.2.5",
304
+ prettier: "^3.3.1",
311
305
  "string.prototype.replaceall": "^1.0.10"
312
306
  },
313
307
  devDependencies: {
314
- "@babel/traverse": "^7.24.1",
315
- "@cyco130/eslint-config": "^3.7.1",
308
+ "@babel/traverse": "^7.24.7",
309
+ "@cyco130/eslint-config": "^3.9.0",
316
310
  "@types/babel__core": "^7.20.5",
317
- "@types/babel__traverse": "^7.20.5",
318
- "@types/node": "20.11.30",
311
+ "@types/babel__traverse": "^7.20.6",
312
+ "@types/node": "20.14.2",
319
313
  eslint: "^8.57.0",
320
- rimraf: "^5.0.5",
321
- tsup: "^8.0.2",
322
- typescript: "^5.4.3",
323
- vitest: "1.4.0"
314
+ rimraf: "^5.0.7",
315
+ tsup: "^8.1.0",
316
+ typescript: "^5.4.5",
317
+ vitest: "1.6.0"
324
318
  },
325
319
  repository: {
326
320
  type: "git",
@@ -399,8 +393,7 @@ async function cli(...args2) {
399
393
  await mkdir(import_node_path.default.normalize(output), { recursive: true });
400
394
  for (const dir of dirs) {
401
395
  const outDir = import_node_path.default.join(output, import_node_path.default.relative(input, dir));
402
- if (outDir === output)
403
- continue;
396
+ if (outDir === output) continue;
404
397
  await mkdir(import_node_path.default.normalize(outDir), { recursive: true });
405
398
  }
406
399
  for (const file of files) {
package/dist/index.js CHANGED
@@ -133,8 +133,7 @@ async function removeTypes(code, fileName, options) {
133
133
  code = processMagicComments(code);
134
134
  const removeComments = {
135
135
  enter(p) {
136
- if (!p.node.leadingComments)
137
- return;
136
+ if (!p.node.leadingComments) return;
138
137
  for (let i = p.node.leadingComments.length - 1; i >= 0; i--) {
139
138
  const comment = p.node.leadingComments[i];
140
139
  if (code.slice(comment.end).match(/^\s*\n\s*\n/) || comment.value.includes("@detype: empty-line")) {
@@ -179,8 +178,7 @@ async function removeTypes(code, fileName, options) {
179
178
  );
180
179
  }
181
180
  async function removeTypesFromVueSfcScript(code, fileName, script, templateAst, options) {
182
- if (script === null || script.lang !== "ts")
183
- return code;
181
+ if (script === null || script.lang !== "ts") return code;
184
182
  if (script.setup && templateAst) {
185
183
  const expressions = /* @__PURE__ */ new Set();
186
184
  (0, import_template_ast_types.traverse)(templateAst, {
@@ -218,12 +216,10 @@ function processMagicComments(input) {
218
216
  let start = input.indexOf(REPLACE_COMMENT);
219
217
  while (start >= 0) {
220
218
  const middle = input.indexOf(WITH_COMMENT, start);
221
- if (middle < 0)
222
- return input;
219
+ if (middle < 0) return input;
223
220
  const middleEnd = middle + WITH_COMMENT.length;
224
221
  const end = input.indexOf(END_COMMENT, middleEnd);
225
- if (end < 0)
226
- return input;
222
+ if (end < 0) return input;
227
223
  const endEnd = end + END_COMMENT.length;
228
224
  const before = input.slice(0, start);
229
225
  const newText = input.slice(middleEnd, end).replaceAll(/^\s*\/\//gm, "");
@@ -241,12 +237,10 @@ async function removeMagicComments(code, fileName, prettierOptions) {
241
237
  let startEnd = start + REPLACE_COMMENT.length;
242
238
  while (start >= 0) {
243
239
  const middle = code.indexOf(WITH_COMMENT, start);
244
- if (middle < 0)
245
- return code;
240
+ if (middle < 0) return code;
246
241
  const middleEnd = middle + WITH_COMMENT.length;
247
242
  const end = code.indexOf(END_COMMENT, middleEnd);
248
- if (end < 0)
249
- return code;
243
+ if (end < 0) return code;
250
244
  const endEnd = end + END_COMMENT.length;
251
245
  const before = code.slice(0, start);
252
246
  const keptText = code.slice(startEnd, middle);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "detype",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Removes TypeScript type annotations but keeps the formatting",
5
5
  "main": "dist/index.js",
6
6
  "bin": "detype.js",
@@ -9,27 +9,27 @@
9
9
  "index.d.ts"
10
10
  ],
11
11
  "dependencies": {
12
- "@babel/core": "^7.24.3",
13
- "@babel/preset-typescript": "^7.24.1",
14
- "@vue/compiler-dom": "^3.4.21",
15
- "@vue/compiler-sfc": "^3.4.21",
12
+ "@babel/core": "^7.24.7",
13
+ "@babel/preset-typescript": "^7.24.7",
14
+ "@vue/compiler-dom": "^3.4.27",
15
+ "@vue/compiler-sfc": "^3.4.27",
16
16
  "@vuedx/compiler-sfc": "0.7.1",
17
17
  "@vuedx/template-ast-types": "0.7.1",
18
18
  "fast-glob": "^3.3.2",
19
- "prettier": "^3.2.5",
19
+ "prettier": "^3.3.1",
20
20
  "string.prototype.replaceall": "^1.0.10"
21
21
  },
22
22
  "devDependencies": {
23
- "@babel/traverse": "^7.24.1",
24
- "@cyco130/eslint-config": "^3.7.1",
23
+ "@babel/traverse": "^7.24.7",
24
+ "@cyco130/eslint-config": "^3.9.0",
25
25
  "@types/babel__core": "^7.20.5",
26
- "@types/babel__traverse": "^7.20.5",
27
- "@types/node": "20.11.30",
26
+ "@types/babel__traverse": "^7.20.6",
27
+ "@types/node": "20.14.2",
28
28
  "eslint": "^8.57.0",
29
- "rimraf": "^5.0.5",
30
- "tsup": "^8.0.2",
31
- "typescript": "^5.4.3",
32
- "vitest": "1.4.0"
29
+ "rimraf": "^5.0.7",
30
+ "tsup": "^8.1.0",
31
+ "typescript": "^5.4.5",
32
+ "vitest": "1.6.0"
33
33
  },
34
34
  "repository": {
35
35
  "type": "git",