diff --git a/angel_serialize_generator/CHANGELOG.md b/angel_serialize_generator/CHANGELOG.md index 7b086e1f..11a75905 100644 --- a/angel_serialize_generator/CHANGELOG.md +++ b/angel_serialize_generator/CHANGELOG.md @@ -1,3 +1,6 @@ +# 2.1.2 +* Add `declare module` to generated TypeScript files. + # 2.1.1 * Generate `hashCode`. diff --git a/angel_serialize_generator/lib/typescript.dart b/angel_serialize_generator/lib/typescript.dart index a90bd213..c3890d2e 100644 --- a/angel_serialize_generator/lib/typescript.dart +++ b/angel_serialize_generator/lib/typescript.dart @@ -156,9 +156,9 @@ class TypeScriptDefinitionBuilder implements Builder { buf.writeln('// GENERATED CODE - DO NOT MODIFY BY HAND'); // declare module `foo` { - //buf - // ..writeln("declare module '${buildStep.inputId.package}' {") - // ..indent(); + buf + ..writeln("declare module '${buildStep.inputId.package}' {") + ..indent(); for (var ctx in contexts) { // interface Bar { ... } @@ -190,9 +190,9 @@ class TypeScriptDefinitionBuilder implements Builder { } } - //buf - // ..outdent() - // ..writeln('}'); + buf + ..outdent() + ..writeln('}'); var finalBuf = new CodeBuffer(); refs.forEach(finalBuf.writeln); buf.copyInto(finalBuf); diff --git a/angel_serialize_generator/pubspec.yaml b/angel_serialize_generator/pubspec.yaml index 02332c04..65d0e63b 100644 --- a/angel_serialize_generator/pubspec.yaml +++ b/angel_serialize_generator/pubspec.yaml @@ -1,5 +1,5 @@ name: angel_serialize_generator -version: 2.1.1 +version: 2.1.2 description: Model serialization generators, designed for use with Angel. Combine with angel_serialize for flexible modeling. author: Tobe O homepage: https://github.com/angel-dart/serialize diff --git a/angel_serialize_generator/test/models/author.d.ts b/angel_serialize_generator/test/models/author.d.ts index 25ddec6b..64f0baf1 100644 --- a/angel_serialize_generator/test/models/author.d.ts +++ b/angel_serialize_generator/test/models/author.d.ts @@ -1,19 +1,21 @@ /// // GENERATED CODE - DO NOT MODIFY BY HAND -interface Library { - id?: string; - collection?: LibraryCollection; - created_at?: any; - updated_at?: any; -} -interface LibraryCollection { - [key: string]: Book; -} -interface Bookmark { - id?: string; - history?: number[]; - page: number; - comment?: string; - created_at?: any; - updated_at?: any; +declare module 'angel_serialize_generator' { + interface Library { + id?: string; + collection?: LibraryCollection; + created_at?: any; + updated_at?: any; + } + interface LibraryCollection { + [key: string]: Book; + } + interface Bookmark { + id?: string; + history?: number[]; + page: number; + comment?: string; + created_at?: any; + updated_at?: any; + } } \ No newline at end of file diff --git a/angel_serialize_generator/test/models/book.d.ts b/angel_serialize_generator/test/models/book.d.ts index 676749be..e67cc967 100644 --- a/angel_serialize_generator/test/models/book.d.ts +++ b/angel_serialize_generator/test/models/book.d.ts @@ -1,12 +1,14 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -interface Book { - id?: string; - author?: string; - title?: string; - description?: string; - page_count?: number; - not_models?: number[]; - camelCase?: string; - created_at?: any; - updated_at?: any; +declare module 'angel_serialize_generator' { + interface Book { + id?: string; + author?: string; + title?: string; + description?: string; + page_count?: number; + not_models?: number[]; + camelCase?: string; + created_at?: any; + updated_at?: any; + } } \ No newline at end of file