GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — module: do not attempt to strip type when there's no source · nodejs/node@100225f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/modules
    • esm
      • get_format.js
    • helpers.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/modules/esm/get_format.js‎

Copy file name to clipboardExpand all lines: lib/internal/modules/esm/get_format.js
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,12 @@ function getFileProtocolModuleFormat(url, context = { __proto__: null }, ignoreE
160160
default: { // The user did not pass `--experimental-default-type`.
161161
// `source` is undefined when this is called from `defaultResolve`;
162162
// but this gets called again from `defaultLoad`/`defaultLoadSync`.
163-
const { tsParse } = require('internal/modules/helpers');
164-
const parsedSource = tsParse(source);
163+
let parsedSource;
164+
if (source) {
165+
// We do the type stripping only if `source` is not falsy.
166+
const { tsParse } = require('internal/modules/helpers');
167+
parsedSource = tsParse(source);
168+
}
165169
const detectedFormat = detectModuleFormat(parsedSource, url);
166170
// When source is undefined, default to module-typescript.
167171
const format = detectedFormat ? `${detectedFormat}-typescript` : 'module-typescript';
Collapse file

‎lib/internal/modules/helpers.js‎

Copy file name to clipboardExpand all lines: lib/internal/modules/helpers.js
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,7 @@ function loadTypeScriptParser(parser) {
331331
* @returns {string} JavaScript code.
332332
*/
333333
function tsParse(source) {
334-
// TODO(@marco-ippolito) Checking empty string or non string input should be handled in Amaro.
335-
if (!source || typeof source !== 'string') { return ''; }
334+
assert(typeof source === 'string');
336335
const parse = loadTypeScriptParser();
337336
const { code } = parse(source);
338337
return code;

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.