[ddc] Migrate js_typerep libraries to null safety

Change-Id: I73a1f7da1c62bc12d832da7d22a5288425ee99aa
Issue: https://github.com/dart-lang/sdk/issues/46617
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223362
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
diff --git a/pkg/dev_compiler/lib/src/compiler/js_typerep.dart b/pkg/dev_compiler/lib/src/compiler/js_typerep.dart
index c1291a3..e0d73cb 100644
--- a/pkg/dev_compiler/lib/src/compiler/js_typerep.dart
+++ b/pkg/dev_compiler/lib/src/compiler/js_typerep.dart
@@ -1,7 +1,8 @@
+// Copyright (c) 2017, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
 /// An abstraction of the JS types
-
-// @dart = 2.9
-
 abstract class JSType {
   const JSType();
 
@@ -20,7 +21,7 @@
   bool get isFalsey;
 
   /// The JS `typeof` value, if unambiguous.
-  String get primitiveTypeOf => null;
+  String? get primitiveTypeOf => null;
 
   static const jsBoolean = JSBoolean();
   static const jsNumber = JSNumber();
diff --git a/pkg/dev_compiler/lib/src/kernel/js_typerep.dart b/pkg/dev_compiler/lib/src/kernel/js_typerep.dart
index 646f17c..58297dc 100644
--- a/pkg/dev_compiler/lib/src/kernel/js_typerep.dart
+++ b/pkg/dev_compiler/lib/src/kernel/js_typerep.dart
@@ -2,12 +2,11 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:kernel/class_hierarchy.dart';
 import 'package:kernel/core_types.dart';
 import 'package:kernel/kernel.dart';
 import 'package:kernel/type_environment.dart';
+
 import '../compiler/js_typerep.dart';
 import 'kernel_helpers.dart';
 
@@ -32,9 +31,8 @@
   @override
   JSType typeFor(DartType type) {
     while (type is TypeParameterType) {
-      type = (type as TypeParameterType).parameter.bound;
+      type = type.parameter.bound;
     }
-    if (type == null) return JSType.jsUnknown;
     assert(isKnownDartTypeImplementor(type));
 
     // Note that this should be changed if Dart gets non-nullable types
@@ -65,11 +63,12 @@
     return JSType.jsObject;
   }
 
-  /// Given a Dart type return the known implementation type, if any.
-  /// Given `bool`, `String`, or `num`/`int`/`double`,
-  /// returns the corresponding class in `dart:_interceptors`:
-  /// `JSBool`, `JSString`, and `JSNumber` respectively, otherwise null.
-  Class getImplementationClass(DartType t) {
+  /// Returns the known implementation type for [t], if any.
+  ///
+  /// Given `bool`, `String`, or `num`/`int`/`double`, returns the corresponding
+  /// class in `dart:_interceptors`: `JSBool`, `JSString`, and `JSNumber`
+  /// respectively, otherwise null.
+  Class? getImplementationClass(DartType t) {
     var rep = typeFor(t);
     // Number, String, and Bool are final
     if (rep == JSType.jsNumber) return _jsNumber;