ember-cli / ember-cli

The Ember.js command line utility.

Home Page:https://cli.emberjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

You passed the '--typescript' flag but there is no TypeScript blueprint available. A JavaScript blueprint will be generated instead.

alakameljebali opened this issue · comments

Summary

The --typescript flag does not work with the ember new command and generates a JavaScript blueprint instead.

Steps to reproduce

  1. Run ember new project --package-manager=pnpm --typescript --interactive
  2. Answer the prompts as follows:
  • Is this an app or an addon? App
  • Please provide the spoken/content language of your app: fr-FR
  • Which CI provider do you want to use? Ignore/Skip
  1. Observe the output of the command

Expected behavior

The command should create a new Ember app with TypeScript support and generate a TypeScript blueprint.

Actual behavior

The command creates a new Ember app but prints the following message multiple times:

You passed the '--typescript' flag but there is no TypeScript blueprint available. A JavaScript blueprint will be generated instead.

The command then generates a JavaScript blueprint instead of a TypeScript blueprint.

Environment

  • Ember CLI version: 5.5.0
  • Operating system: Linux Fedora 39
  • Node.js Version: 20.10.0
  • Package manager: pnpm

The warning comes from here

if (!isTypeScriptFile(fileInfo.outputPath)) {
// If the user wants TypeScript output but there is no TypeScript blueprint available, we want
// to warn them that they're not going to get what they're expecting while still at least giving
// them the JS output. We check for this *after* checking `shouldTranformTypeScript` because
// it's possible for people to set `{typescript: true}` in their `.ember-cli` file, which would
// then erroneously trigger this message every time they generate a JS blueprint even though
// they didn't pass the flag.
if (options.typescript === true && isJavaScriptFile(fileInfo.outputPath)) {
this.ui.writeLine(
chalk.yellow(
"You passed the '--typescript' flag but there is no TypeScript blueprint available. " +
'A JavaScript blueprint will be generated instead.'
)
);
}

I suspect it is from files like config/targets.js and ember-cli-build.js etc

Can we make the message more friendly, maybe include the filename that outputs the warning?

Maybe something like

You passed the '--typescript' flag, we're just letting you know that ${fileInfo.outputPath} will be generated as a JavaScript file as it is run directly through node.

Had a new user confused with the output
https://discord.com/channels/480462759797063690/486548111221719040/1206049226480558100

I think ideally we should remove the warning for the ones we expect to be javascript.

I could be wrong, but it's probably "hard" to know which files are expected to be JavaScript without maintaining a hardcoded list? Which doesn't feel ideal. I was thinking we could just remove the warning altogether?

I think that is fine, but we should ask @emberjs/core-typescript -- @wagenet @gitKrystan?

I'm in favor of removing the warning altogether.