Allow comment-based type annotations to use forward references without using string literals.

This commit is contained in:
Eric Traut 2020-05-15 20:44:30 -07:00
parent 5bb39c8a71
commit 3c182c523d

View File

@ -934,6 +934,11 @@ export function createTypeEvaluator(importLookup: ImportLookup, printTypeFlags:
evaluatorFlags |= EvaluatorFlags.AllowForwardReferences;
}
// If the annotation is part of
if (node?.parent?.nodeType === ParseNodeType.Assignment && node.parent.typeAnnotationComment === node) {
evaluatorFlags |= EvaluatorFlags.AllowForwardReferences;
}
if (!allowFinal) {
evaluatorFlags |= EvaluatorFlags.FinalDisallowed;
}