Skip to main content
Filter by
Sorted by
Tagged with
Tooling
0 votes
2 replies
59 views

I am using optional chaining quite often, but so far never encounter that issue, until today: if both items can be undefined, rather don't use optional chaining. Only last test (below) can help in ...
allez l'OM's user avatar
0 votes
0 answers
77 views

When designing TypeScript props for React components, I'm sometimes unsure whether I should type props like: prop?: Type or prop: Type | undefined My understanding so far: prop?: Type The prop ...
Andrey Rafalskyi's user avatar
1 vote
1 answer
162 views

I have this problem - I cannot use Tailwind in my project or optional chaining operator (?.) because VSCode adds an extra whitespace after a colon or after a dot. In case of taiwind, it adds a ...
jj j's user avatar
  • 59
0 votes
1 answer
78 views

I am using TypeScript 5.7.3. Installed @types/[email protected]. TypeScript config: { "compilerOptions": { "target": "ES2020", "moduleResolution": &...
Daniel Gruszczyk's user avatar
4 votes
2 answers
258 views

We have an application that needs to be supported in old Chrome (v79). Angular Version 13.2.7 Typescript Version 4.5.5 Node Version 16.14.0 We are getting an error: ERROR: Big integer literals are not ...
Ajit Hingmire's user avatar
1 vote
2 answers
96 views

I'm using an Optional.of chain in Java to get a value, Integer yearOfBirth = Optional.ofNullable(employee) .map(Employee::getDateOfBirth) ....
mccarthyj's user avatar
  • 949
-6 votes
1 answer
164 views

The use case is a user/client sends a request to a server running PHP. I am trying to write the PHP code on the server e.g. an API endpoint to process the request. I have existing production PHP code ...
user6631314's user avatar
  • 2,050
8 votes
6 answers
2k views

In Javascript, if I have a potentially null object obj, which, if not null, will have a field x - I can write obj?.x. This is called "optional chaining" or "safe navigation": If ...
einpoklum's user avatar
  • 137k
0 votes
1 answer
392 views

I have scenario in my project that a common shared service having a common variable (object) to store nested objects. I have to access and update its value in html using NgModel. Optional-chaining ...
Anupam Sharma's user avatar
0 votes
1 answer
121 views

I came across the below code: public void method(MyObject obj) { String value = Optional.ofNullable(obj) .map(x -> obj.doSomething()) ....
Gautham M's user avatar
  • 4,996
0 votes
1 answer
174 views

I've encountered an unexpected behavior while using the Optional API in Java. Session session = sessionService .getSessionById(id) .orElse( ...
Souhaib's user avatar
  • 119
0 votes
1 answer
172 views

In VSCode, IntelliSense is saying a property does not exist on an object in a TypeScript file even when I specify the optional chaining syntax to short-circuit the error. The code compiles correctly ...
Rob W's user avatar
  • 23
1 vote
1 answer
88 views

I struggle with finding an elegant way to convert a variable of type Optional<String[]> to Optional<String> and joining all elements of the given array. Is there an elegant solution for ...
Oliver's user avatar
  • 4,273
0 votes
0 answers
138 views

I am working on Python code where the domain logic makes it natural to have a class with an optional field of a second class, which itself has an optional field of a third class. Boiling it down to a ...
Erlend Magnus Viggen's user avatar
2 votes
2 answers
256 views

in a node repl or browser console: > ({})?.a undefined > (null)?.a undefined > (null)?.a.b undefined > ({})?.a.b Uncaught TypeError: Cannot read properties of undefined (reading 'b') if (...
dtudury's user avatar
  • 639
-2 votes
1 answer
61 views

So this piece of code public boolean getBoolean(Integer Id) { return Optional.of(Store.getMagazin(Id)) .map(MagazinDO::getBoolean) .orElse(Boolean.FALSE);} returns a null while ...
butertoast's user avatar
1 vote
2 answers
662 views

The issue was encountered after installing the aws s3 sdk. I followed the suggested solutions from all other similar problems in the following manner: -updated node version (even though I had version ...
SENA rajaguru's user avatar
4 votes
1 answer
109 views

Consider the following code: public class Main { public static void main(String[] args) // throws Exception // line 1 { Optional empty1 = Optional.empty(); // line 2 ...
Sy Pham's user avatar
  • 109
0 votes
1 answer
759 views

I don't think I understand how optional chaining affects the async/await functions. I have a simple function that returns the user from Firebase Auth. export async function getCurrentUser() { const ...
Alex's user avatar
  • 49
2 votes
1 answer
325 views

I'm having trouble making my method null-safe using streams and flatMap.. My input is a List<RequestSlot> And the objects are nested as such: Request OuterItem ...
N.A's user avatar
  • 311
-1 votes
1 answer
94 views

Use Java 8 Optional features in the multiple null conditions The conditions is Optional<Payee> payee = Optional.ofNullable(paymtTrans.getPayee()); if (payee.isPresent() &...
Kishore_2021's user avatar
-1 votes
1 answer
335 views

As you can see in the picture, my syntax highlighting stops working just after I used an optional chaining in my JSX file. Please let me know how can I fix the problem. enter image description here I ...
AliReza's user avatar
  • 19
0 votes
3 answers
104 views

I have a nested object which can return a null at any point of time. Thanks to Optional and map we can now do nested calls without having to put null checks after every get. I have a very unique ...
Nick Div's user avatar
  • 5,656
1 vote
1 answer
877 views

When I do this: var resetButton = document.querySelector('.resetButton'); resetButton?.onclick = function() { //... }; I got error: Uncaught SyntaxError: invalid assignment left-hand side. I ...
Zorro's user avatar
  • 1,639
0 votes
0 answers
38 views

In Swift I can do the following which would 1- make sure that none of these properties are nil and 2- give me access to them safely unwrapped: // user could be nil, and lat and lon are properties on ...
Lance Samaria's user avatar
0 votes
0 answers
120 views

I received an error in React w/ Typescript says possiblyUndefined is possibly undefined. So I threw it in an if statement that specifics checks that it's defined before running the function inside the ...
Cjmaret's user avatar
  • 329
2 votes
2 answers
1k views

I ran these experiments in the Chrome console: a = {} -> {} a.n.n.n.n.n.n.n -> Uncaught TypeError: Cannot read properties of undefined (reading 'n') a?.n.n.n.n.n.n.n -> Uncaught ...
Martin Geisse's user avatar
2 votes
0 answers
930 views

I am having an issue when I am trying to use the aws-sdk v3. I am confident it is because of the optional chaining used in this node module file. ERROR in ./node_modules/@aws-sdk/signature-v4/dist-es/...
mg123's user avatar
  • 31
1 vote
1 answer
892 views

I have a simple data class such as @Data @Builder public class MyPerson implements Serializable { String name; String age; //Purposely keeping as String here String address; } After ...
mitriola's user avatar
0 votes
1 answer
301 views

I have such code: if (action?.notificationKey && state.notifications[action.notificationKey]) { delete state.notifications[action.notificationKey]; } which does not satisfy me, because ...
ddominoo's user avatar
0 votes
0 answers
1k views

I am stuck in an issue. I can't even start making the change to the project as its not even starting. installed all the dependencies and when i started by yarn start then i got this issue. I tried to ...
Pranshu_Taneja's user avatar
0 votes
2 answers
2k views

I would like to use Java 11's Optional to protect myself from the dreaded null pointer exception. I wrote a basic test to check my understanding of how they work. like. so @Test public void ...
codernoob8's user avatar
10 votes
3 answers
25k views

i tried to use optional chaining in javascript but my eslint rules causing error . Error : Unsafe usage of optional chaining. If it short-circuits with 'undefined' the evaluation will throw TypeError ...
V2rson's user avatar
  • 357
-1 votes
3 answers
585 views

I'm working on building a very basic news app using the New York Times' 'top stories' API. The API is well documented and there are plenty of examples of how to get stared online. But I'm stuck with ...
joe44's user avatar
  • 13
1 vote
0 answers
257 views

I have vue project and i have installed few packages. When I do npm run dev it throws error for adding appropriate loader. It seems like packages I have installed have `optional-chaining code and ...
Raj Patil's user avatar
1 vote
2 answers
1k views

I had written a code of which a rough snippet is as follows: boolean isCalledFromAction = Optional.ofNullable(requestParams.get(IS_CALLED_FROM_ACTION)) .map(val -> true)...
GAURAV KABRA's user avatar
0 votes
0 answers
1k views

./src/components/BookDetails/bookdetails.jsx 147:14 Module parse failed: Unexpected token (147:14) You may need an appropriate loader to handle this file type. | } | }, /*#__PURE__*/React....
bana2544's user avatar
-1 votes
2 answers
269 views

I have this Try it Yourself TypeScript Optional Chaining example from W3Schools TypeScript Null & Undefined section in screenshot below. I can see that the purpose of the example is to show you ...
Rob Wilkinson's user avatar
1 vote
2 answers
774 views

I have this type: type ErrorMessages = Record<number | 'default', string>; Then, when I define a variable as const text: ErrorMessages = {403: 'forbidden'}, Typescript says that default is ...
Jöcker's user avatar
  • 7,048
1 vote
1 answer
374 views

How can I use a property of an interface as a type for a variable in typescript ?? Here I want to access the property: string type and use it as a type for a variable but I cannot access it. interface ...
Rocky's user avatar
  • 117
0 votes
0 answers
21 views

I have a type definition with an optional member which I need to access in a function. In order to assure that the optional member is indeed set, I created a "validator"-function which ...
Lukas Kimpel's user avatar
1 vote
0 answers
553 views

I am currently refactoring some old code and thus dealing with many redundant conditional checks. Here is a short example: <div *ngIf="user" title="{{user?.name}}"> <...
connectedMind's user avatar
2 votes
1 answer
222 views

I want to increment an object value using the optional chaning operator (?.). In my example I want to increase the age of a Person by one in a function called birthday() only if an age is set for the ...
Fulligan's user avatar
0 votes
0 answers
395 views

we're all familiar with the tune?.image type of null checks in Typescript optional chaining docs but what's the best practice for checking this with an array value? tune.images?[0] will not work. I ...
dcsan's user avatar
  • 12.5k
6 votes
3 answers
2k views

Is there any reason to use if to check if method exists, before calling await if (someObject.save){ await someObject.save(); } rather than using nullish coallescence diectly with await await ...
husayt's user avatar
  • 15.3k
0 votes
0 answers
134 views

I have just come across this.person!.name in my codebase, previously I have seen this.person?.name which is optional chaining, but I have never seen ! be used nor can I find any resource to explain it'...
Udders's user avatar
  • 7,048
-1 votes
1 answer
142 views

[Disclaimer] I do not encourage anyone to do prototype modification in anyone's code, specially shared (or meant to play along with other's). This is bad practice (if not plain evil). Much like force-...
Ar3s's user avatar
  • 2,317
0 votes
1 answer
65 views

I use qooxdoo 6.0 version. Optional chaing is a very useful feature, is there a way to use it in qooxdoo?
Jaejin Jang's user avatar
2 votes
3 answers
1k views

If a function f: (X => Y) | undefined is possibly undefined, and x: X is defined, then we can use optional-chaining operator ?. to apply f to x: f?.(x) // ok, no problem if `f` is ...
Andrey Tyukin's user avatar
0 votes
1 answer
429 views

I have a scenario where I am reading a yaml file and based upon the data, make calls to tag aws resources. await Promise.all(doc?.SQS.map(async (queue)=>{ // code to tag 1 queue })) Now the yaml ...
Naxi's user avatar
  • 2,264