packages/@css-blocks/core/src/BlockTree/Block.ts:443:48 - error TS2339: Property 'value' does not exist on type 'never'.
443 let klass = otherBlock.getClass(next.value);
~~~~~
packages/@css-blocks/core/src/BlockTree/Block.ts:445:32 - error TS2339: Property 'next' does not exist on type 'never'.
445 let another = next.next();
~~~~
To repro:
1) yarn
2) tsc -b -f packages
This appears to be a correct error. The relevant code looks like this (highlights for emphasis):
let next = node.next();
if (isRootNode(node) && next && isAttributeNode(next) && typeof next.namespace === "string") {
// ^^^^^^^^^^^^^^^^^^^^^
let otherBlock = this.getReferencedBlock(next.namespace);
if (otherBlock) {
if (next && isClassNode(next)) {
// ^^^^^^^^^^^^^^^^^
let klass = otherBlock.getClass(next.value);
isAttributeNode returns arg is Attribute where Attribute is { type: "Attribute" }. isClassNode returns arg is ClassName where ClassName is { type: "Class" }. I don't see any other out-of-band assignments to next; I think this code actually does have a bug in it either from a runtime perspective or from an incorrect typings perspective - no value could satisfy both of those conditions.
cc file authors @chriseppstein @ramitha @amiller-gh for commentary
@RyanCavanaugh Is there some way we could make it easier to work backwards from the error to the problem? Maybe the if block could report that its condition is unsatisfiable?
I'll look into this right now.
Looks like the error was introduced in https://github.com/linkedin/css-blocks/commit/b9c493866f0cf6916e0ce03a3c9988830e3b2c44
This is what the isAttributeNode() type check was previously: https://github.com/linkedin/css-blocks/blame/3dcd62065bc2a56ce2367f6a813379d06f16cbc2/packages/@css-blocks/core/src/BlockTree/Block.ts#L397
I agree with @RyanCavanaugh that this code block isn't reachable and I think the error is very helpful... I wish I would have had it earlier! I agree with @amcasey that an error telling me that one of the branches of the if statement isn't reachable would be a slightly nicer error, but I think I would have been able to sort out my mistake based on the error as-is.
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes.
Most helpful comment
I agree with @RyanCavanaugh that this code block isn't reachable and I think the error is very helpful... I wish I would have had it earlier! I agree with @amcasey that an error telling me that one of the branches of the
ifstatement isn't reachable would be a slightly nicer error, but I think I would have been able to sort out my mistake based on the error as-is.