-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LUAFDN-250 - Add types for connect and dispatch prop (#68)
This PR adds types for the dispatch prop and connect. This includes a standard action dispatch and a thunkful action dispatch variant. Note that I used the thunkful action dispatch as the default for connect(), which may or may not be desirable, but felt like a better default to me. Inspired by: https://github.com/reduxjs/react-redux/blob/master/src/types.ts This RP also adds typechecking to CI with luau-lsp.
- Loading branch information
1 parent
d7ef4d8
commit a22d98b
Showing
14 changed files
with
169 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -10,6 +10,32 @@ on: | |
- master | ||
|
||
jobs: | ||
analyze: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: true | ||
|
||
- name: Install foreman tools | ||
uses: Roblox/setup-foreman@v1 | ||
with: | ||
version: "^1.0.1" | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Download global Roblox types | ||
shell: bash | ||
run: curl -s -O https://raw.githubusercontent.com/JohnnyMorganz/luau-lsp/master/scripts/globalTypes.d.lua | ||
|
||
- name: Generate sourcemap for LSP | ||
shell: bash | ||
run: rojo sourcemap default.project.json -o sourcemap.json | ||
|
||
- name: Analyze | ||
shell: bash | ||
run: luau-lsp analyze --sourcemap=sourcemap.json --defs=globalTypes.d.lua --defs=testez.d.lua src/ | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
|
||
|
@@ -30,11 +56,6 @@ jobs: | |
luarocks install luacov | ||
luarocks install luacov-reporter-lcov | ||
- name: Test | ||
run: | | ||
lua -lluacov test/lemur.lua | ||
luacov -r lcov | ||
- name: install code quality tools | ||
uses: Roblox/setup-foreman@v1 | ||
with: | ||
|
@@ -47,6 +68,16 @@ jobs: | |
selene src | ||
stylua -c src/ | ||
- name: install and run darklua | ||
run: | | ||
cargo install --git https://gitlab.com/seaofvoices/darklua.git#v0.6.0 | ||
darklua process src/ src/ --format retain-lines | ||
- name: Test | ||
run: | | ||
lua -lluacov test/lemur.lua | ||
luacov -r lcov | ||
- name: Report to Coveralls | ||
uses: coverallsapp/[email protected] | ||
with: | ||
|
This file contains 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 |
---|---|---|
|
@@ -13,3 +13,6 @@ | |
# Rotriever | ||
rotriever.lock | ||
Packages | ||
|
||
# Misc OS | ||
.DS_Store |
This file contains 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 |
---|---|---|
@@ -1,6 +1,23 @@ | ||
{ | ||
"name": "RoactRodux", | ||
"tree": { | ||
"$path": "src" | ||
"$className": "Folder", | ||
"Roact": { | ||
"$path": "modules/roact/src", | ||
".luaurc": { | ||
"$className": "StringValue", | ||
"$path": "modules/.luaurc" | ||
} | ||
}, | ||
"Rodux": { | ||
"$path": "modules/rodux/src", | ||
".luaurc": { | ||
"$className": "StringValue", | ||
"$path": "modules/.luaurc" | ||
} | ||
}, | ||
"RoactRodux": { | ||
"$path": "src" | ||
} | ||
} | ||
} | ||
} |
This file contains 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 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,5 @@ | ||
{ | ||
"languageMode": "nocheck", | ||
"lint": { "*": false }, | ||
"lintErrors": false | ||
} |
Submodule lemur
updated
6 files
+23 −0 | lib/Habitat.lua | |
+4 −0 | lib/createEnvironment.lua | |
+14 −0 | lib/libs/debug.lua | |
+29 −0 | lib/libs/debug_spec.lua | |
+1 −0 | lib/libs/init.lua | |
+52 −0 | spec/loadmodule_spec.lua |
Submodule rodux
updated
48 files
This file contains 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 |
---|---|---|
|
@@ -8,4 +8,4 @@ files = ["*", "!*.spec.lua"] | |
|
||
[dependencies] | ||
Roact = "github.com/roblox/[email protected]" | ||
Rodux = "github.com/roblox/rodux@3.0" | ||
Rodux = "github.com/roblox/rodux@4.0.0-rc.0" |
This file contains 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 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 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 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 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,30 @@ | ||
--!strict | ||
local Rodux = require(script.Parent.Parent.Rodux) | ||
|
||
type Action = Rodux.Action<string> | ||
type ThunkAction<ReturnType, State> = Rodux.ThunkAction<ReturnType, State> | ||
type ActionCreator<Type, Action, Args...> = Rodux.ActionCreator<Type, Action, Args...> | ||
|
||
export type DispatchProp = <Payload>(action: Payload & Action) -> () | ||
|
||
export type ThunkfulDispatchProp<State = any> = | ||
DispatchProp | ||
& <ReturnType>(thunkAction: ThunkAction<ReturnType, State>) -> ReturnType | ||
|
||
export type MapStateToProps<StoreState, Props, PartialProps> = (StoreState, Props) -> PartialProps? | ||
|
||
export type MapStateToPropsOrThunk<StoreState, Props, PartialProps> = | ||
MapStateToProps<StoreState, Props, PartialProps> | ||
| () -> MapStateToProps<StoreState, Props, PartialProps> | ||
|
||
export type ActionCreatorMap = { | ||
[string]: ActionCreator<any, any, ...any>, | ||
} | ||
|
||
export type MapDispatchToProps<StoreState, PartialProps> = (ThunkfulDispatchProp<StoreState>) -> PartialProps? | ||
|
||
export type MapDispatchToPropsOrActionCreator<StoreState, PartialProps> = | ||
MapDispatchToProps<StoreState, PartialProps> | ||
| ActionCreatorMap | ||
|
||
return nil |
This file contains 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,24 @@ | ||
declare function afterAll(callback: () -> ()): () | ||
declare function afterEach(callback: () -> ()): () | ||
|
||
declare function beforeAll(callback: () -> ()): () | ||
declare function beforeEach(callback: () -> ()): () | ||
|
||
declare function describe(phrase: string, callback: () -> ()): () | ||
declare function describeFOCUS(phrase: string, callback: () -> ()): () | ||
declare function fdescribe(phrase: string, callback: () -> ()): () | ||
declare function describeSKIP(phrase: string, callback: () -> ()): () | ||
declare function xdescribe(phrase: string, callback: () -> ()): () | ||
|
||
declare function expect(value: any): any | ||
|
||
declare function FIXME(optionalMessage: string?): () | ||
declare function FOCUS(): () | ||
declare function SKIP(): () | ||
|
||
declare function it(phrase: string, callback: () -> ()): () | ||
declare function itFOCUS(phrase: string, callback: () -> ()): () | ||
declare function fit(phrase: string, callback: () -> ()): () | ||
declare function itSKIP(phrase: string, callback: () -> ()): () | ||
declare function xit(phrase: string, callback: () -> ()): () | ||
declare function itFIXME(phrase: string, callback: () -> ()): () |