MCPcopy Create free account
hub / github.com/ember-cli/ember-cli / shouldConvertToJS

Function shouldConvertToJS

lib/models/blueprint.js:482–512  ·  view source on GitHub ↗

@private @method shouldConvertToJS @param {Object} options @param {FileInfo} fileInfo @return {Boolean}

(options, fileInfo)

Source from the content-addressed store, hash-verified

480 @return {Boolean}
481 */
482 shouldConvertToJS(options, fileInfo) {
483 // If this isn't turned on, it doesn't matter what else was passed, we're not touching it.
484 if (!this.shouldTransformTypeScript) {
485 return false;
486 }
487
488 // If the blueprint isn't a TS file to begin with, there's nothing to convert.
489 if (!isTypeScriptFile(fileInfo.outputPath)) {
490 return false;
491 }
492
493 // Indicates when the user explicitly passed either `--typescript` or `--no-typescript` as opposed
494 // to not passing a flag at all and allowing for default behavior
495 const userExplicitlySelectedTypeScriptStatus = options.typescript !== undefined;
496
497 // Indicates when the user has asked for TypeScript either globally (by setting
498 // `isTypeScriptProject` to true) or locally (by passing the `--typescript` flag when they
499 // invoked the generator). Although ember-cli merges `.ember-cli` and all of the flag values into
500 // one object, we thought the DX would be improved by differentiating between what is intended
501 // to be global vs. local config.
502 const shouldUseTypeScript = userExplicitlySelectedTypeScriptStatus
503 ? options.typescript
504 : options.isTypeScriptProject;
505
506 // if the user wants TS output and we have a TS file available, we do *not* want to downlevel to JS
507 if (shouldUseTypeScript) {
508 return false;
509 }
510
511 return true;
512 },
513
514 /**
515 @private

Callers

nothing calls this directly

Calls 1

isTypeScriptFileFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…