π Search Terms
unintentinal, comparison, 2367, overlap
π Version & Regression Information
- typescript:
v7.0.2
- node:
v24.14.1
- pnpm:
v12.3.4
β― Playground Link
No response
π» Code
let n: "a" | "b" = "a";
const updateN = () => {
n = "b";
};
// This comparison appears to be unintentional because the types '"a"' and '"b"' have no overlap. [2367]
if (n === "b") {}
updateN();
// This comparison appears to be unintentional because the types '"a"' and '"b"' have no overlap. [2367]
if (n === "b") {}
n = "b";
// No error
if (n === "b") {}
π Actual behavior
If a variable of type "a" | "b" is changed in a function with closure, the LSP fails to catch the change, and assumes that it was never changed.
π Expected behavior
No error warning, since code works as expected
Additional information about the issue
No response
π Search Terms
unintentinal, comparison, 2367, overlap
π Version & Regression Information
v7.0.2v24.14.1v12.3.4β― Playground Link
No response
π» Code
π Actual behavior
If a variable of type
"a" | "b"is changed in a function with closure, the LSP fails to catch the change, and assumes that it was never changed.π Expected behavior
No error warning, since code works as expected
Additional information about the issue
No response