TypeScript Standalone #3
Merged
ollieatkinson merged 10 commits intothousandyears:trunkfrom Aug 12, 2022
Merged
Conversation
steprescott
reviewed
May 27, 2022
Member
steprescott
left a comment
There was a problem hiding this comment.
Great stuff Tom. Thanks for your contribution.
Member
|
Could you also add your generator to the list of generators found here. |
steprescott
reviewed
May 27, 2022
Member
|
@tomsugarev I had a go at playing with the generated TS code, looks really good - I have a couple of small suggestions:
This makes the auto-complete super clean: Access to the identifier can be done through subscript: test.one['identifier'] // "test.one"Example Generated Code interface I { }
// L
class L implements I {
protected __: string;
constructor(id: string) {
this.__ = id;
}
get [Symbol.toStringTag]() {
return this.__;
}
get ['identifier']() {
return this.__;
}
}
// MARK: generated types
class L_test extends L implements I_test {
one = new L_test_one(`${this.__}.one`);
two = new L_test_two(`${this.__}.two`);
type = new L_test_type(`${this.__}.type`);
}
interface I_test extends I {
one: I_test_one;
two: I_test_two;
type: I_test_type;
}
class L_test_one extends L implements I_test_one {
good!: L_test_type_odd_good;
more = new L_test_one_more(`${this.__}}.more`);
}
interface I_test_one extends I_test_type_odd {
more: I_test_one_more;
}
class L_test_one_more extends L implements I_test_one_more {
time = new L_test_one_more_time(`${this.__}}.time`);
}
interface I_test_one_more extends I {
time: I_test_one_more_time;
}
class L_test_one_more_time extends L implements I_test_one_more_time {
one!: L_test_one;
two!: L_test_two;
type!: L_test_type;
}
type I_test_one_more_time = I_test;
class L_test_two extends L implements I_test_two {
no!: L_test_type_even_no;
bad!: L_test_type_even_bad;
timing = new L_test_two_timing(`${this.__}}.timing`);
}
interface I_test_two extends I_test_type_even {
timing: I_test_two_timing;
}
class L_test_two_timing extends L implements I_test_two_timing {
}
type I_test_two_timing = I;
class L_test_type extends L implements I_test_type {
even = new L_test_type_even(`${this.__}}.even`);
odd = new L_test_type_odd(`${this.__}}.odd`);
}
interface I_test_type extends I {
even: I_test_type_even;
odd: I_test_type_odd;
}
class L_test_type_even extends L implements I_test_type_even {
no = new L_test_type_even_no(`${this.__}}.no`);
bad = this.no.good;
}
interface I_test_type_even extends I {
no: I_test_type_even_no;
}
type L_test_type_even_bad = L_test_type_even_no_good
class L_test_type_even_no extends L implements I_test_type_even_no {
good = new L_test_type_even_no_good(`${this.__}}.good`);
}
interface I_test_type_even_no extends I {
good: I_test_type_even_no_good;
}
class L_test_type_even_no_good extends L implements I_test_type_even_no_good {
}
type I_test_type_even_no_good = I;
class L_test_type_odd extends L implements I_test_type_odd {
good = new L_test_type_odd_good(`${this.__}}.good`);
}
interface I_test_type_odd extends I {
good: I_test_type_odd_good;
}
class L_test_type_odd_good extends L implements I_test_type_odd_good {
}
type I_test_type_odd_good = I;
const test = new L_test("test"); |
Member
ollieatkinson
approved these changes
Aug 12, 2022
Member
ollieatkinson
left a comment
There was a problem hiding this comment.
Awesome @tomsugarev - let's get this in the next release of MindFlare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Typescript generator
Bit of extra fiddling compared to Swift and Kotlin.
Looking at the
L_test_oneclass inTSit needs to explicitly state thegoodproperty.In Swift/Kotlin it doesn't. Guess this is a difference in the protocol(interface) inheritance??