-
Notifications
You must be signed in to change notification settings - Fork 34
[interop] Add Support for Typealiases #407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2b0e7c3
Interop Gen: Support Typealiases
nikeokoronkwo 3b53965
Refactored fix for typealias use in type generics: awaiting review
nikeokoronkwo 2a994c8
Merge main into typealias branch
nikeokoronkwo 9c04149
fixed type argument issue: awaiting resolution
nikeokoronkwo fff6e2f
added filtering case support for `TypeAliasDeclaration`
nikeokoronkwo d774c5a
Formatting files
nikeokoronkwo 6e8e3a1
Fixed standing issue
nikeokoronkwo 96fad76
Changed dart formatter version to match `web_generator` version
nikeokoronkwo adb3361
Added support for referring defined types:
nikeokoronkwo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
web_generator/test/integration/interop_gen/typealias_expected.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// ignore_for_file: constant_identifier_names, non_constant_identifier_names | ||
|
||
// ignore_for_file: no_leading_underscores_for_library_prefixes | ||
import 'dart:js_interop' as _i1; | ||
|
||
typedef Username = String; | ||
typedef Age = double; | ||
typedef IsActive = bool; | ||
typedef Tags = _i1.JSArray<_i1.JSString>; | ||
typedef List<T extends _i1.JSAny?> = _i1.JSArray<T>; | ||
typedef Box<T extends _i1.JSAny?> = _i1.JSArray<_i1.JSArray<T>>; | ||
typedef PromisedArray<U extends _i1.JSAny?, T extends _i1.JSArray<U>> | ||
= _i1.JSPromise<T>; | ||
typedef Shape2D = String; | ||
typedef PrismFromShape2D<S extends _i1.JSString> = _i1.JSArray<S>; | ||
typedef Logger = LoggerType; | ||
typedef Direction = AnonymousUnion; | ||
typedef Method = AnonymousUnion$1; | ||
@_i1.JS() | ||
external LoggerContainer<_i1.JSNumber> get loggerContainers; | ||
@_i1.JS() | ||
external Logger myLogger; | ||
@_i1.JS() | ||
external Method get requestMethod; | ||
@_i1.JS() | ||
external Username get username; | ||
@_i1.JS() | ||
external Age get age; | ||
@_i1.JS() | ||
external _i1.JSArray<Tags> get tagArray; | ||
@_i1.JS() | ||
external List<_i1.JSString> get users; | ||
@_i1.JS() | ||
external Box<_i1.JSNumber> get matrix; | ||
@_i1.JS() | ||
external PrismFromShape2D<_i1.JSString> makePrism(Shape2D shape); | ||
@_i1.JS('makePrism') | ||
external PrismFromShape2D<S> makePrism$1<S extends _i1.JSString>(S shape); | ||
@_i1.JS() | ||
external PromisedArray<_i1.JSString, _i1.JSArray<_i1.JSString>> fetchNames(); | ||
@_i1.JS() | ||
external String isUserActive(IsActive status); | ||
extension type const LoggerType._(int _) { | ||
static const LoggerType Noop = LoggerType._(0); | ||
|
||
static const LoggerType Stdout = LoggerType._(1); | ||
|
||
static const LoggerType Stderr = LoggerType._(2); | ||
|
||
static const LoggerType File = LoggerType._(3); | ||
|
||
static const LoggerType Other = LoggerType._(4); | ||
} | ||
extension type const AnonymousUnion._(String _) { | ||
static const AnonymousUnion N = AnonymousUnion._('N'); | ||
|
||
static const AnonymousUnion S = AnonymousUnion._('S'); | ||
|
||
static const AnonymousUnion E = AnonymousUnion._('E'); | ||
|
||
static const AnonymousUnion W = AnonymousUnion._('W'); | ||
} | ||
extension type const AnonymousUnion$1._(String _) { | ||
static const AnonymousUnion$1 GET = AnonymousUnion$1._('GET'); | ||
|
||
static const AnonymousUnion$1 POST = AnonymousUnion$1._('POST'); | ||
|
||
static const AnonymousUnion$1 PUT = AnonymousUnion$1._('PUT'); | ||
|
||
static const AnonymousUnion$1 DELETE = AnonymousUnion$1._('DELETE'); | ||
|
||
static const AnonymousUnion$1 PATCH = AnonymousUnion$1._('PATCH'); | ||
|
||
static const AnonymousUnion$1 OPTIONS = AnonymousUnion$1._('OPTIONS'); | ||
} | ||
typedef LoggerContainer<N extends _i1.JSNumber> = _i1.JSArray<N>; |
32 changes: 32 additions & 0 deletions
32
web_generator/test/integration/interop_gen/typealias_input.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
declare enum LoggerType { | ||
Noop = 0, | ||
Stdout = 1, | ||
Stderr = 2, | ||
File = 3, | ||
Other = 4 | ||
} | ||
export type Username = string; | ||
export type Age = number; | ||
export type IsActive = boolean; | ||
export type Tags = string[]; | ||
export type List<T> = T[]; | ||
export type Box<T> = Array<Array<T>>; | ||
export type PromisedArray<U, T extends Array<U>> = Promise<T>; | ||
nikeokoronkwo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
export type Shape2D = string; | ||
export type PrismFromShape2D<S extends Shape2D> = Array<S>; | ||
export type Logger = LoggerType; | ||
export type Direction = "N" | "S" | "E" | "W"; | ||
export type Method = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS"; | ||
type LoggerContainer<N extends number> = N[]; | ||
export declare const loggerContainers: LoggerContainer<Logger>; | ||
export declare let myLogger: Logger; | ||
export declare const requestMethod: Method; | ||
export declare const username: Username; | ||
export declare const age: Age; | ||
export declare const tagArray: Tags[]; | ||
export declare const users: List<Username>; | ||
export declare const matrix: Box<number>; | ||
export declare function makePrism(shape: Shape2D): PrismFromShape2D<Shape2D>; | ||
export declare function makePrism<S extends Shape2D>(shape: S): PrismFromShape2D<S>; | ||
export declare function fetchNames(): PromisedArray<string, string[]>; | ||
export declare function isUserActive(status: IsActive): string; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.