1- import getTemplateDefinition from '@codesandbox/common/lib/templates' ;
1+ import getTemplateDefinition , {
2+ TemplateType ,
3+ } from '@codesandbox/common/lib/templates' ;
24import {
35 Module ,
46 ModuleTab ,
@@ -175,8 +177,8 @@ export const saveCode: AsyncAction<{
175177} ;
176178
177179export const updateCurrentTemplate : AsyncAction = async ( {
178- state,
179180 effects,
181+ state,
180182} ) => {
181183 try {
182184 const currentTemplate = state . editor . currentSandbox . template ;
@@ -187,9 +189,9 @@ export const updateCurrentTemplate: AsyncAction = async ({
187189 // in the sandbox configuration.
188190 if (
189191 templateDefinition . isServer ||
190- state . editor . parsedConfigurations . sandbox . parsed . template
192+ state . editor . parsedConfigurations ? .sandbox ? .parsed ? .template
191193 ) {
192- const { parsed } = state . editor . parsedConfigurations . package ;
194+ const { parsed = { } } = state . editor . parsedConfigurations ? .package || { } ;
193195
194196 const modulesByPath = mapValues ( state . editor . modulesByPath , module => ( {
195197 // No idea why this typing fails!
@@ -199,10 +201,10 @@ export const updateCurrentTemplate: AsyncAction = async ({
199201 isBinary : module . isBinary ,
200202 } ) ) ;
201203
202- // TODO: What is a templat really? Two different kinds of templates here, need to fix the types
204+ // TODO: What is a template really? Two different kinds of templates here, need to fix the types
203205 // Talk to Ives and Bogdan
204- const newTemplate =
205- computeTemplate ( parsed , modulesByPath ) || ( 'node' as any ) ;
206+ const newTemplate = ( computeTemplate ( parsed , modulesByPath ) ||
207+ 'node' ) as TemplateType ;
206208
207209 if (
208210 newTemplate !== currentTemplate &&
0 commit comments