@@ -118,7 +118,7 @@ def install_inertia
118118 ERB
119119 insert_into_file application_layout . to_s , headers , after : "<%= vite_client_tag %>\n "
120120
121- if framework == ' react' && !application_layout . read . include? ( 'vite_react_refresh_tag' )
121+ if react? && !application_layout . read . include? ( 'vite_react_refresh_tag' )
122122 say 'Adding Vite React Refresh tag to the application layout'
123123 insert_into_file application_layout . to_s , "<%= vite_react_refresh_tag %>\n " ,
124124 before : '<%= vite_client_tag %>'
@@ -130,7 +130,7 @@ def install_inertia
130130 say_error '- <title>...</title>'
131131 say_error '+ <title data-inertia>...</title>'
132132 say_error '+ <%= inertia_ssr_head %>'
133- say_error '+ <%= vite_react_refresh_tag %>' if framework == ' react'
133+ say_error '+ <%= vite_react_refresh_tag %>' if react?
134134 say_error "+ <%= #{ vite_tag } %>"
135135 end
136136 end
@@ -148,14 +148,30 @@ def install_typescript
148148
149149 add_dependencies ( *FRAMEWORKS [ framework ] [ 'packages_ts' ] )
150150
151- say 'Copying adding scripts to package.json'
151+ say 'Copying tsconfig and types'
152+
153+ # Copy tsconfig files
154+ tsconfig_files = %w[ tsconfig.json tsconfig.node.json ]
155+ tsconfig_files << 'tsconfig.app.json' unless svelte?
156+
157+ tsconfig_files . each do |file |
158+ template "#{ framework } /#{ file } " , file_path ( file )
159+ end
160+
161+ # Copy type definition files
162+ types_files = %w[ types/vite-env.d.ts types/globals.d.ts types/index.ts ]
163+ types_files . each do |file |
164+ template "#{ framework } /#{ file } " , file_path ( "#{ js_destination_path } /#{ file } " )
165+ end
166+
167+ say 'Adding TypeScript check scripts to package.json'
152168 if svelte?
153169 run 'npm pkg set scripts.check="svelte-check --tsconfig ./tsconfig.json && tsc -p tsconfig.node.json"'
154- end
155- if framework == 'vue'
170+ elsif react?
171+ run 'npm pkg set scripts.check="tsc -p tsconfig.app.json && tsc -p tsconfig.node.json"'
172+ elsif vue?
156173 run 'npm pkg set scripts.check="vue-tsc -p tsconfig.app.json && tsc -p tsconfig.node.json"'
157174 end
158- run 'npm pkg set scripts.check="tsc -p tsconfig.app.json && tsc -p tsconfig.node.json"' if framework == 'react'
159175 end
160176
161177 def install_example_page
@@ -327,6 +343,10 @@ def react?
327343 framework . start_with? 'react'
328344 end
329345
346+ def vue?
347+ framework . start_with? 'vue'
348+ end
349+
330350 def inertia_package
331351 "#{ FRAMEWORKS [ framework ] [ 'inertia_package' ] } @#{ options [ :inertia_version ] } "
332352 end
0 commit comments