anchor.diff:    }
   
     // "Left Null".
  -  if (${_equalType(t1, Null)}) {
  +  if (_equalType(t1, Null)) {
       // TODO(nshahan) Need to handle type variables.
       // https://github.com/dart-lang/sdk/issues/38816
  -    if (${_isFutureOr(t2)}) {
  -      let t2TypeArg = ${getGenericArgs(t2)}[0];
  -      return $_isSubtype($Null, t2TypeArg, $strictMode);
  -    }
  -
  -    return ${_equalType(t2, Null)} || ${_jsInstanceOf(t2, LegacyType)} ||
  -        ${_jsInstanceOf(t2, NullableType)};
  +    if (_isFutureOr(t2)) {
  +      var t2TypeArg = JS('', '#[0]', getGenericArgs(t2));
  +      return _isSubtype(typeRep<Null>(), t2TypeArg, strictMode);
  +    }
  +
  +    return _equalType(t2, Null) ||
  +        _jsInstanceOf(t2, LegacyType) ||
  +        _jsInstanceOf(t2, NullableType);
     }
   
     // "Left Legacy".
  -  if (${_jsInstanceOf(t1, LegacyType)}) {
  -    return $_isSubtype(t1.type, t2, $strictMode);
  +  if (_jsInstanceOf(t1, LegacyType)) {
  +    return _isSubtype(JS<LegacyType>('!', '#', t1).type, t2, strictMode);
     }
   
     // "Right Legacy".
  -  if (${_jsInstanceOf(t2, LegacyType)}) {
  -    return $_isSubtype(t1, $nullable(t2.type), $strictMode);
  +  if (_jsInstanceOf(t2, LegacyType)) {
  +    return _isSubtype(
  +        t1, nullable(JS<LegacyType>('!', '#', t2).type), strictMode);
     }
   
     // Handle FutureOr<T> union type.
  -  if (${_isFutureOr(t1)}) {
  -    let t1TypeArg = ${getGenericArgs(t1)}[0];
  -    if (${_isFutureOr(t2)}) {
  -      let t2TypeArg = ${getGenericArgs(t2)}[0];
  +  if (_isFutureOr(t1)) {
  +    var t1TypeArg = JS('!', '#[0]', getGenericArgs(t1));
  +    if (_isFutureOr(t2)) {
  +      var t2TypeArg = JS('!', '#[0]', getGenericArgs(t2));
         // FutureOr<A> <: FutureOr<B> if A <: B
  -      if ($_isSubtype(t1TypeArg, t2TypeArg, $strictMode)) {
  +      if (_isSubtype(t1TypeArg, t2TypeArg, strictMode)) {
           return true;
         }
       }
   
       // given t1 is Future<A> | A, then:
       // (Future<A> | A) <: t2 iff Future<A> <: t2 and A <: t2.
  -    let t1Future = ${getGenericClassStatic<Future>()}(t1TypeArg);
  +    var t1Future = JS('!', '#(#)', getGenericClassStatic<Future>(), t1TypeArg);
       // Known to handle the case FutureOr<Null> <: Future<Null>.
  -    return $_isSubtype(t1Future, $t2, $strictMode) &&
  -        $_isSubtype(t1TypeArg, $t2, $strictMode);
  +    return _isSubtype(t1Future, t2, strictMode) &&
  +        _isSubtype(t1TypeArg, t2, strictMode);
     }
   
     // "Left Nullable".
  -  if (${_jsInstanceOf(t1, NullableType)}) {
  +  if (_jsInstanceOf(t1, NullableType)) {
       // TODO(nshahan) Need to handle type variables.
       // https://github.com/dart-lang/sdk/issues/38816
  -    return $_isSubtype(t1.type, t2, $strictMode) && $_isSubtype($Null, t2, $strictMode);
  -  }
  -
  -  if ($_isFutureOr($t2)) {
  +    return _isSubtype(JS<NullableType>('!', '#', t1).type, t2, strictMode) &&
  +        _isSubtype(typeRep<Null>(), t2, strictMode);
  +  }
  +
  +  if (_isFutureOr(t2)) {
       // given t2 is Future<A> | A, then:
       // t1 <: (Future<A> | A) iff t1 <: Future<A> or t1 <: A
  -    let t2TypeArg = ${getGenericArgs(t2)}[0];
  -    let t2Future = ${getGenericClassStatic<Future>()}(t2TypeArg);
  +    var t2TypeArg = JS('!', '#[0]', getGenericArgs(t2));
  +    var t2Future = JS('!', '#(#)', getGenericClassStatic<Future>(), t2TypeArg);
       // TODO(nshahan) Need to handle type variables on the left.
       // https://github.com/dart-lang/sdk/issues/38816
  -    return $_isSubtype($t1, t2Future, $strictMode) || $_isSubtype($t1, t2TypeArg, $strictMode);
  +    return _isSubtype(t1, t2Future, strictMode) ||
  +        _isSubtype(t1, t2TypeArg, strictMode);
     }
   
     // "Right Nullable".
  -  if (${_jsInstanceOf(t2, NullableType)}) {
  +  if (_jsInstanceOf(t2, NullableType)) {
       // TODO(nshahan) Need to handle type variables.
       // https://github.com/dart-lang/sdk/issues/38816
  -    return $_isSubtype(t1, t2.type, $strictMode) || $_isSubtype(t1, $Null, $strictMode);
  +    return _isSubtype(t1, JS<NullableType>('!', '#', t2).type, strictMode) ||
  +        _isSubtype(t1, typeRep<Null>(), strictMode);
     }
   
     // "Traditional" name-based subtype check.  Avoid passing
     // function types to the class subtype checks, since we don't
     // currently distinguish between generic typedefs and classes.
  -  if (!${_jsInstanceOf(t2, AbstractFunctionType)}) {
  +  if (!_jsInstanceOf(t2, AbstractFunctionType)) {
       // t2 is an interface type.
   
  -    if (${_jsInstanceOf(t1, AbstractFunctionType)}) {
  +    if (_jsInstanceOf(t1, AbstractFunctionType)) {
         // Function types are only subtypes of interface types `Function` (and top
         // types, handled already above).
  -      return ${_equalType(t2, Function)};
  +      return _equalType(t2, Function);
       }
   
       // Even though lazy and anonymous JS types are natural subtypes of
  
positive.code:     // JavaScriptObject <: package:js types
      // package:js types <: JavaScriptObject
  
      if (${_isInterfaceSubtype(t1, JavaScriptObject, strictMode)}
          &&
              // TODO: Since package:js types are instances of PackageJSType and
              // we don't have a mechanism to determine if *some* package:js type
              // implements t2. This will possibly require keeping a map of these
              // relationships for this subtyping check. For now, this will only
              // work if t2 is also a PackageJSType.
              ${_isInterfaceSubtype(_pkgJSTypeForSubtyping, t2, strictMode)}) {
        return true;
      }
  
      if (${_isInterfaceSubtype(JavaScriptObject, t2, strictMode)}
          && ${_isInterfaceSubtype(t1, _pkgJSTypeForSubtyping, strictMode)}) {
        return true;
      }
  
      // Compare two interface types.
      return ${_isInterfaceSubtype(t1, t2, strictMode)};
    }
  
    // Function subtyping.
    if (!${_jsInstanceOf(t1, AbstractFunctionType)}) {
      return false;
    }
  
    // Handle generic functions.
    if (${_jsInstanceOf(t1, GenericFunctionType)}) {
      if (!${_jsInstanceOf(t2, GenericFunctionType)}) {
        return false;
      }
  
  
negative.code: })()''');
  
  /// Returns true if [ft1] <: [ft2].
  @notNull
  bool _isFunctionSubtype(ft1, ft2, @notNull bool strictMode) =>
      JS<bool>('!', '''(() => {
    let ret1 = $ft1.returnType;
    let ret2 = $ft2.returnType;
  
  