-
Notifications
You must be signed in to change notification settings - Fork 41
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
Convert src/ to TypeScript #68
Conversation
If we enable power-assert, some tests cannot be succeed. We need to clarify it. But we disable it to proceed to convert TypeScript.
r? @azu |
Thanks. |
getState() { | ||
return this._storeGroup.getState(); | ||
getState<T>(): T { | ||
return (this._storeGroup as any).getState(); // TODO: remove casting `any` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 I have no idea about this.
Can we remove this casting by some changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought to introduce some new interfaces which is implemented by StoreGroup
or Store
to fix it.
Perhaps is it not a right way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, This fix should be later.
@@ -32,14 +34,14 @@ export let defaultStoreName = "<Anonymous-Store>"; | |||
* Store class | |||
* @public | |||
*/ | |||
export default class Store extends Dispatcher { | |||
abstract class Store extends Dispatcher { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Store
is not abstruct in some test case.
Line 12 in e2daa2f
const store = new Store(); |
Is it valid in TypeScript?
Of course, Store
is just abstract in most case without testing, I think.
Should we will modify test code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it valid in TypeScript?
"At this time", it's valid in TypeScript because we keep all unit test cases as plain js.
However, of course, we need to add class TestStore extends Store
to them if we convert test cases to TypeScript.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I've checked this PR.
The first overview is looks good to me.
Thanks for nice work.
@@ -48,6 +50,9 @@ export default class Store extends Dispatcher { | |||
return false | |||
} | |||
|
|||
name: string; | |||
displayName: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, displayName
is optional.
* unique id in each UseCase instances. | ||
*/ | ||
id: string; | ||
displayName: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto.
displayName
is optional
I've merged this. Next StepsWe will continue to investigate following TODO issues. |
Abstract
d.ts
in npm, we need push more patch onto this.Motivation
Detailed Design
Change build system
This introduces 2-phase build system.
src/
withtsc
and emit a plain JS code into/__obj/
temp dir.In this phase, this also try to copy all javascript file into
/__obj/
to keep the content of/src/
.babel
and emit the transformed one into/lib/
.By this change, we can achive to convert our source code to TypeScript incrementally without at giant single patch file.
Unit tese imports from
/lib/
By the above change, we need to load the code to test unit tests for incremental converting without changeing
unit tests.
Convert TypeScript
Convert
*.js
to*.ts
simply.This change escapes from the problem which is that some dependency does not have any
d.ts
by dirty hacking.Add
*.d.ts
and*.js
with same name. TypeScript compiler uses*.d.ts
to resolve type checking.But we use
*.js
file to load a file actually on the runtime. This dirty hack resolves the problem.Drawback
Alternative Approach
But this tries to use TypeScript by conversations with @azu.
Unresolved Items
*.d.ts
files into/lib/
: feat(typescript): add d.ts to pacakge.json #78.any
type from public APIs:abstract
correctly.