-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
DeclinedThe issue was declined as something which matches the TypeScript visionThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
π Search Terms
typescript ? operator with !
π Version & Regression Information
Versions tested : 5.9.3 and 5.6.3
β― Playground Link
No response
π» Code
interface A {
b?: string;
}
function tt(v?: A) {
const str: string = v?.b!;
return str;
}
console.log("Value : ", tt());π Actual behavior
The result is : "Value : undefined"
π Expected behavior
Compilator must refuse to combine ? before an !
v?.b! must to be refuse by typescript compilator. We must do "v!.b!" to have the good type.
Additional information about the issue
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
DeclinedThe issue was declined as something which matches the TypeScript visionThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScriptAn idea for TypeScript