I use the result of a function that handles one field, it removes the connected union type information for that field.
see code and error here:
https://www.typescriptlang.org/play?#code/LAKAlgdgLgpgTgMwIYGMYAIAiMJgF44CqEADknAM4wAmASjCmCTAMoAWSzANjBRegG9Q6EeigBPZgC50AcgoduvCrOGjIJAK5QZFKHEgBzUAF9QoSLESoM2XAQjEylGvUbN2nGoLUiJ0uQUvalUQUXQNbV19IwBtAF1Tc3BoeGQ0LBx8IlJyKjoGJhgAMU04CBsfMNF-GBlZBDKKtFDw2RQAew6AawB9KDAAWxhZaIMIY2qRSJ10PXHJsxALVOsMu2zHXJcC91YoDogGbQGJqvDa+r1D46hTw1b1Uii5mImk5ZSrdNsshzcip4lHxzjVJHVAooYDw+I9ps9ZvM4okQEsVt9Kht-oUPFDqKC-OCrni4REEWNkQkPui0pi-jgAcxSuVKkIpmIiXJGiyWr45J0ev0hiMKe92TNRYtkpZaet6RBGfsbigTkYCRyAvIDkcVXcjKSJa8FtSQLVMvYGTiMABec2bRVA6HKdAAHzt2L2jvxbqxlr2zOaGB98od2tu93QADJ1R1tFooL0AI6aJDQMASGQQTSDABG8BNZt9W2c+UV6FtRaceVcVsdMP4wYtxeru0BeNd7pyJZr-qalUbmyrO1DytVZ2jbPCsag8aTKbTGfQWdz+dRyU6ED06G7RcVAEkEeX0AAKOBWmSV7alq0ASnLAD51WAECez3sAHRm622+RQ+uyO8zygJp0DfIp3xmd8KBILh02PWQXQAvln1fK1P3BcsfyCZgQkAmBgPKUC0MgwZOGPMAHwiKCYLghCAJvPkgJAsDmAghETQ3LcdxDK0j1Pc9O2bYdbwvHi9ko49J1Ed8ZJYmAABpkPJbdq13K0D3jfi9gY1EbyAA
yep I was right.. I need to tell TS to keep the union information :< const parseDenizenRecipeInput = (recipe: DenizenUnparsedRecipe) => { if (recipe.type == 'shapeless') return { ...recipe, input: recipe.input.split('|') } if (recipe.type == 'shaped') return { ...recipe, input: recipe.input.map(i => i.split('|')) } return recipe } const parseDenizenRecipe = (recipe: DenizenUnparsedRecipe): DenizenRecipe => ({ ...recipe, ...parseDenizenRecipeInput(recipe) })
Обсуждают сегодня