4 ms·
I Hate "Unknown"
Does anybody else think unknown is a useless, worthless, hateful bug in Typescript? There has never been a single time when it helped me and it annoys me 100% of the time. Why isn't there a way to turn it off?
I'm so mad right now because there's no tsconfig option to turn it off. Why not. Does anybody smarter than me have a good explanation for why they put it in so I can quit getting mad when it says this:
```
const d = reactive({
searchText: "",
customers: null as any[], <-- Conversion of type 'null' to type 'any[]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.ts(2352)
page: 1,
perPage: 10,
gettingCustomers: false,
error: ""
});
```
- compressedgas 2y agoWhy not use an empty array instead of null for the default value?
- deleted 2y ago[deleted]
- deleted 2y ago[deleted]
- joegibbs 2y agoWhy null as any[]? Can’t it just be []?
- h_tbob 2y agoActually, if you do that you get: "Property 'email' does not exist on type 'never'.ts(2339)" When you do {{customer.email}}
- alpinisme 2y agoUse `[] as TheRealType`. `any` is the real wart on the language, not unknown, which adds safety by preventing you from doing anything dangerous with it.