[P2] Checker: optional member calls reject string-or-undefined receivers
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- csharp, typescript
- Domain
- compilers
Research direction
The payload names no source file, so start by reproducing the snippet with --no-tsconfig --lib es2022,dom in both interpret and compile modes. Then find where the message "Cannot invoke an object which is possibly 'undefined'" is produced in the checker. Done when the snippet prints true in both modes and the optional call on a string | undefined receiver no longer errors.
Written by the indexing model from the issue text.
Description
The checker rejects a valid optional member call on a nullable string receiver.
function run(value: string | undefined) {
console.log(value?.includes("x") === undefined);
}
run(undefined);
Strict TypeScript accepts this program and Node prints true. Both SharpTS interpretation and compilation reject it before execution with Cannot invoke an object which is possibly 'undefined'.
Reproduced with --no-tsconfig --lib es2022,dom. The optional member access should short-circuit the following call when the receiver is undefined. This report contains no non-null assertion, grouped optional-call boundary, or optional argument/default behavior.
- Dominant language
- C#
- Stars
- 156
- Forks
- 4
- Avg merge
- 13h 33m
- Merged PRs (30d)
- 45
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nickna/SharpTS
-
bug priority: P2
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
bug priority: P3
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
bug priority: P2
Difficulty 5/5 Over a week Newbie friendliness 15/100
Maintainers usually reply within 1 day
-
bug priority: P2
Difficulty 4/5 3-5 days Newbie friendliness 22/100
Maintainers usually reply within 1 day
-
bug priority: P2
Difficulty 4/5 3-5 days Newbie friendliness 30/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
libnativeapi/nativeapi#21 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 3 days
-
enhancement P3 performance
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
thomhurst/TUnit#7380 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
Maintainers usually reply within 1 day