google / json_serializable.dart

Generates utilities to aid in serializing to/from JSON.
https://pub.dev/packages/json_serializable
BSD 3-Clause "New" or "Revised" License
1.55k stars 395 forks source link

FromJson generated function violates strict-raw-types language rule #1324

Closed johnpryan closed 1 year ago

johnpryan commented 1 year ago

When strict-raw-types is enabled, the generated code produces a warning:

Meta _$MetaFromJson(Map json) => $checkedCreate(
warning • lib/workshops/src/meta.g.dart:9:21 • The generic type 'Map<dynamic, dynamic>' should have explicit type arguments but doesn't. Use explicit type arguments for 'Map<dynamic, dynamic>'. • strict_raw_type
johnpryan commented 1 year ago

This could be user-error... Here's the PR that upgrades DartPad's packages and generates the code in question: https://github.com/dart-lang/dart-pad/pull/2537/files#diff-071bfc91ddc6e946fd3acdf30253c80cd2456a26ec7562a83fc47166068167b5

kevmoo commented 1 year ago

duplicate of https://github.com/google/json_serializable.dart/issues/517

It makes code SUPER crazy. Suggest just ignoring this error in generated code per https://github.com/dart-lang/source_gen#configuring-combining_builder

johnpryan commented 1 year ago

Sounds good, we can put an ignore in the preamble.