C
C#

help

ToastElement

Ffroxerbbq11/28/2022
Hello guys, I am going through a project and found some things not working, this is one of the errors that I could not solve easily by myself as typescript is a greener area for me Error TS2722 (TS) Cannot invoke an object which is possibly 'undefined'. D:\asd\Web\ClientApp\tsconfig.json
D:\asd\ToastElement.spec.tsx beforeEach(() => { wrapper.find(Toast).props().onClose(); });
This is occuring in a ToastElement.spec.tsx file Best Regards Let me know if u need more information
AAnton11/28/2022
that's a typescript nullability warning basically one of those things in that call chain returns something that can be undefined (basically the same as null) you need to check for nulls or use the null forgiving operator the if-null (?) and null-forgiving (!) work the same way in typescript as in c# @wiz
Ffroxerbbq11/28/2022
Hi, sorry my son was going crazyt I tried to but couldn't figure out where to place a null check operator
AAnton11/28/2022
after find probably try splitting it on to multiple lines, and see on which line the error is, if your editor isn't configured for ts
Ffroxerbbq11/28/2022
Just turns into this:
Ffroxerbbq11/28/2022
The condition will always return true since this function is always defined. Did you mean to call it instead? And Property 'props' does not exist on type 'typeof Toast'.
Ffroxerbbq11/28/2022
This is not throwing a error
AAnton11/28/2022
um that's not how you use that operator
Ffroxerbbq11/28/2022
ok
Ffroxerbbq11/28/2022
I am used to C#.net, don't have much time in TS.
AAnton11/28/2022
it's the same in typescipt tho
Ffroxerbbq11/28/2022
from what I know u use it before a member for example .?property
AAnton11/28/2022
but not before a function name i mean, after
Ffroxerbbq11/28/2022
no
AAnton11/28/2022
before parameter list
Ffroxerbbq11/28/2022
only before param ye
AAnton11/28/2022
no, not before parameter list, that's not allowed even in c# even though hm it might be allowed in ts
Ffroxerbbq11/28/2022
I didn't mean in C#, in C# from what I know I only use it before members of objects. But I am just getting back more into coding, I have been in a integration team for the past 4 years so bit rusty.
AAnton11/28/2022
put it after calling find find(Toast)?.whatever that would make way more sense
Ffroxerbbq11/28/2022
ok Does onClose require a ()? it is complaining about Cannot invoke an object which is possibly 'undefined'.
AAnton11/28/2022
in c# you'd do onClose?.Invoke()
Ffroxerbbq11/28/2022
yeah
AAnton11/28/2022
I don't know how you do that in typescrpt, probably onClose?.invoke(), but you should google this
Ffroxerbbq11/28/2022
I was meant to create a health check in a microservice, it span into me finding bunch of undefined and unknown's that was resolved by for example doing this: addFromException(response as any); in other places.
AAnton11/28/2022
ah you could also adjust the typescipt config
Ffroxerbbq11/28/2022
I read about a flag to ignore these kind of errors in the cfg
AAnton11/28/2022
if you don't really care about those yeah
Ffroxerbbq11/28/2022
suppressImplicitAnyIndexErrors Which is supposed to be in the ts cfg I searched through the azure stack but couldn't find it anywhere else so decided to sit and resolve manually. Now I am starting to think that I am just cluttering the solution. it was only in 10~ places, but still.
AAnton11/28/2022
it's either in the typescript config or in the linter config
Ffroxerbbq11/28/2022
Can't find a linter config in the solution but i did find a tsconfig.json there is a eslintrc.json but it is only warnings
AAnton11/28/2022
TSConfig Reference - Docs on every TSConfig option
From allowJs to useDefineForClassFields the TSConfig reference includes information about all of the active compiler flags setting up a TypeScript project.
Ffroxerbbq11/28/2022
ok, thank you Now I have a error in Index.d.ts Severity Code Description Project File Line Suppression State Error TS2792 (TS) Cannot find module './lib'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option? Miscellaneous C:\Users\z\AppData\Local\Microsoft\TypeScript\4.8\node_modules@types\react-bootstrap\index.d.ts 44 Active
Ffroxerbbq11/28/2022
AAnton11/28/2022
is there a lib file? ah wait what, error in bootstrap?? you should google this one, really no clue
Ffroxerbbq11/28/2022
I am, but after looking through about 10 articles I am not that much smarter

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts
❔ ✅ Tree category EF CoreI Have model: ```cs public class Category { public int Id { get; set; } public string Name ❔ What am I doing wrong?what am i doing wrong?❔ XML serialization woesI'm trying to use XmlSerializer, and for some reason I can't get it to serialize an array of child e❔ Ace value of 1 or 11I am writing a blackjack game. I have written a method to calculate the amount of "score" the player❔ Game Design Brainstorm - Workers, JobsNot Unity's Workers or Jobs; I have an idea for a colony simulator style game, but keep struggling c❔ Does BlockingCollection TryTake free the consuming thread to do other things?I'm not too knowledgeable about multi-threading. But I'm trying to use `BlockingCollection.TryTake` npm version errorHi guys, An old project running core 3.1 is using 11.15.0 of npm, I have previously a installation ❔ HOW CAN I IMPROVE MYSELF AT OOP CsharpI am at new developer at C# and OOP. How can I improve myself about this topic? Any challanges or an❔ Singleton PatternHi in ioc container we have .AddSingleton() method for singleton lifetimes. My question is when we n❔ EntityFramework async where possible?So I want to make sure I don't do something stupid here. I'm trying to convert my DbContext-calls t❔ How to make asp mvc Net 6 and React ecommerce multilingual and multi-currency?I can't find anything about it on the Internet I found some readytouse ecommerce in. Net 6 and Rea❔ Compressing an application with dependenciesIs it possible to put an application with all its dependencies into an .exe?Command WPF with viewmodelHello, i'm looking for some help : I'm currently developing an app with wpf using the mvvm model and✅ How do I make an exponent in winforms?I'm trying to make a random math test simulator for finding the roots of a quadratic equation. I'm n❔ Own map with the possibility of embedding points.Hi, I'm looking for a library that in blazor will allow me to create my own map (with my own backgro❔ .NET 6.0 - Nullable Strings with Dapper Model ClassesHey everyone. I have a .NET 6.0 project that uses Dapper to communicate to a database and I have a c❔ Merging two projects togetherGotta merge two projects together but the issue is some of my partners code is running errors when i❔ ✅ Deserializing a JSON array that contains a derived type AND a base type with JSON.NET?I have three classes: ``` ScratchTarget ├─ ScratchScene └─ ScratchSprite ``` `ScratchTarget`❔ Question How can I get the name of the application the user is currently focused on?So I have a .NET 7.0 app, and I want to see if the app the user is focused on is firefox/chrome, and❔ Assigning variables in switch caseWhy am I getting this error? I want to assign the value of `totalBeat` depending on the sign of `me