-
Notifications
You must be signed in to change notification settings - Fork 34
[interop] Support typeof
type declarations
#417
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
5 commits
Select commit
Hold shift + click to select a range
a30c9be
Interop Gen: Support `typeof` type declarations
nikeokoronkwo 6f76ebb
Merge branch 'main' into interop/typeof
nikeokoronkwo af6e58f
updated examples and code transformation
nikeokoronkwo c2bc8db
formatting
nikeokoronkwo dd21c2c
added documentation
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
46 changes: 46 additions & 0 deletions
46
web_generator/test/integration/interop_gen/ts_typing_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,46 @@ | ||
// 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; | ||
|
||
@_i1.JS() | ||
external String get myString; | ||
@_i1.JS() | ||
external _i1.JSArray<_i1.JSNumber> get myNumberArray; | ||
@_i1.JS() | ||
external String get myCloneString; | ||
@_i1.JS() | ||
external _i1.JSArray<_i1.JSArray<_i1.JSNumber>> get myCloneNumberArray; | ||
extension type const MyEnum._(int _) { | ||
static const MyEnum A = MyEnum._(0); | ||
|
||
static const MyEnum B = MyEnum._(1); | ||
|
||
static const MyEnum C = MyEnum._(2); | ||
|
||
static const MyEnum D = MyEnum._(4); | ||
} | ||
@_i1.JS() | ||
external String myFunction(String param); | ||
@_i1.JS() | ||
external String myEnclosingFunction(_i1.JSFunction func); | ||
@_i1.JS() | ||
external _i1.JSFunction copyOfmyEnclosingFunction; | ||
@_i1.JS() | ||
external MyEnum get myEnumValue; | ||
@_i1.JS() | ||
external MyEnum get myEnumValue2; | ||
@_i1.JS() | ||
external _i1.JSFunction myFunctionAlias; | ||
@_i1.JS() | ||
external _i1.JSFunction myFunctionAlias2; | ||
@_i1.JS() | ||
external _i1.JSFunction get myEnclosingFunctionAlias; | ||
@_i1.JS() | ||
external ComposedType get myComposedType; | ||
@_i1.JS() | ||
external ComposedType<_i1.JSString> get myComposedMyString; | ||
extension type ComposedType<T extends _i1.JSAny?>._(_i1.JSObject _) | ||
implements _i1.JSObject { | ||
external T enclosed; | ||
} |
25 changes: 25 additions & 0 deletions
25
web_generator/test/integration/interop_gen/ts_typing_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,25 @@ | ||
export declare const myString: string; | ||
export declare const myNumberArray: number[]; | ||
export declare const myCloneString: typeof myString; | ||
export declare const myCloneNumberArray: typeof myNumberArray[]; | ||
export declare enum MyEnum { | ||
A = 0, | ||
B = 1, | ||
C = 2, | ||
D = 4 | ||
} | ||
interface ComposedType<T = any> { | ||
enclosed: T; | ||
} | ||
export declare let copyOfmyEnclosingFunction: typeof myEnclosingFunction; | ||
export declare const myEnumValue: MyEnum; | ||
export declare const myEnumValue2: typeof MyEnum; | ||
export declare function myFunction(param: string): string; | ||
export declare let myFunctionAlias: typeof myFunction; | ||
export declare let myFunctionAlias2: typeof myFunctionAlias; | ||
/** @todo [@nikeokoronkwo] support var declarations as well as var statements */ | ||
// export declare let myPreClone: typeof myComposedType; | ||
export declare function myEnclosingFunction(func: typeof myFunction): string; | ||
export declare const myEnclosingFunctionAlias: typeof myEnclosingFunction; | ||
export declare const myComposedType: ComposedType; | ||
export declare const myComposedMyString: ComposedType<typeof myString>; |
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.