| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 417120a commit 100225f
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -160,8 +160,12 @@ function getFileProtocolModuleFormat(url, context = { __proto__: null }, ignoreE | |||
| 160 | 160 | default: { // The user did not pass `--experimental-default-type`. | |
| 161 | 161 | // `source` is undefined when this is called from `defaultResolve`; | |
| 162 | 162 | // 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 | + } | ||
| 165 | 169 | const detectedFormat = detectModuleFormat(parsedSource, url); | |
| 166 | 170 | // When source is undefined, default to module-typescript. | |
| 167 | 171 | const format = detectedFormat ? `${detectedFormat}-typescript` : 'module-typescript'; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -331,8 +331,7 @@ function loadTypeScriptParser(parser) { | |||
| 331 | 331 | * @returns {string} JavaScript code. | |
| 332 | 332 | */ | |
| 333 | 333 | 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'); | ||
| 336 | 335 | const parse = loadTypeScriptParser(); | |
| 337 | 336 | const { code } = parse(source); | |
| 338 | 337 | return code; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments