Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[BUG]: ISO 8601 date string inferred as String? instead of DateTime in Dart output

Aperta
#3,533 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
dart, typescript
Ambito
compilers, tooling

Direzione di ricerca

Reproduce the issue in app.quicktype.io and the quicktype CLI with the supplied JSON and Dart target, checking whether the “Detect dates & times” option is enabled. Trace the date-format inference and Dart generation path; done means the timestamp is inferred as DateTime (or DateTime? with nullability) and the generated code parses and serializes it accordingly.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

ISO 8601 date string inferred as String? instead of DateTime in Dart output

Issue Type

Quicktype output / Type inference issue

Context (Environment, Version, Language)

Input Format: JSON
Output Language: Dart

CLI, npm, or app.quicktype.io: app.quicktype.io / CLI
Version: Latest

Description

ISO 8601 formatted date-time strings (e.g., "2025-08-19T08:08:45.087") are currently being typed as optional String? rather than being detected as DateTime types in Dart code generation. Older versions of quicktype automatically recognized ISO date strings and generated DateTime.parse() / toIso8601String() methods.

Input Data

{
  "LastRecorded": "2025-08-19T08:08:45.087"
}

Expected Behaviour / Output

ISO date-time strings should be inferred as DateTime (or DateTime? if nullability is enabled), producing parsing logic like:

import 'dart:convert';

Welcome welcomeFromJson(String str) => Welcome.fromJson(json.decode(str));

String welcomeToJson(Welcome data) => json.encode(data.toJson());

class Welcome {
    DateTime lastRecorded;

    Welcome({
        required this.lastRecorded,
    });

    factory Welcome.fromJson(Map<String, dynamic> json) => Welcome(
        lastRecorded: DateTime.parse(json["LastRecorded"]),
    );

    Map<String, dynamic> toJson() => {
        "LastRecorded": lastRecorded.toIso8601String(),
    };
}

Current Behaviour / Output

The field is treated as a generic nullable String?:

import 'dart:convert';

Temperatures temperaturesFromJson(String str) => Temperatures.fromJson(json.decode(str));

String temperaturesToJson(Temperatures data) => json.encode(data.toJson());

class Temperatures {
    String? lastRecorded;

    Temperatures({
        this.lastRecorded,
    });

    factory Temperatures.fromJson(Map<String, dynamic> json) => Temperatures(
        lastRecorded: json["LastRecorded"],
    );

    Map<String, dynamic> toJson() => {
        "LastRecorded": lastRecorded,
    };
}

Steps to Reproduce

  1. Open app.quicktype.io (or run quicktype CLI).
  2. Set target language to Dart.
  3. Input JSON containing an ISO 8601 timestamp: {"LastRecorded": "2025-08-19T08:08:45.087"}.
  4. Observe that lastRecorded is generated as String? instead of DateTime.

Possible Solution

Ensure string format inference checks ISO 8601 patterns prior to defaulting to String for Dart generation, or verify that the "Detect dates & times" option setting is active in the Dart target options.

Lingua principale
TypeScript
Stelle
13.9k
Fork
1.2k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di glideapps/quicktype

Tutte le issue di glideapps/quicktype

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.