Skip to content

Commit 30db179

Browse files
committed
feat: re-order typescript prompt
Ask the user if they want to use Typescript before asking which template they'd like to use
1 parent 626603d commit 30db179

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

packages/create/src/index.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,21 @@ export const createSolid = (version: string) =>
6969
})),
7070
}),
7171
);
72+
// Don't offer javascript if `projectType` is library
73+
const useJS =
74+
projectType === "library" ? false : !(await cancelable(p.confirm({ message: "Use Typescript?" })));
75+
7276
const template_opts = getTemplatesList(projectType);
7377
template ??= await cancelable(
7478
p.select({
7579
message: "Which template would you like to use?",
7680
initialValue: "ts",
77-
options: template_opts.map((s: string) => ({ label: s, value: s })),
81+
options: template_opts.filter(s => useJS ? s : !s.startsWith("js")).map((s: string) => ({ label: s, value: s })),
7882
}),
7983
);
80-
81-
// Don't transpile project if it's already javascript!
82-
const transpileToJS =
83-
projectType === "library"
84-
? false
85-
: template.startsWith("js")
86-
? false
87-
: !(await cancelable(p.confirm({ message: "Use Typescript?" })));
88-
84+
85+
// Need to transpile if the user wants Jabascript, but their selected template isn't Javascript
86+
const transpileToJS = useJS && !template.startsWith("js")
8987
if (projectType === "start") {
9088
await spinnerify({
9189
startText: "Creating project",

0 commit comments

Comments
 (0)