Skip to content
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

Missing type definition for typescript #26

Open
c3s4 opened this issue Jun 6, 2019 · 1 comment
Open

Missing type definition for typescript #26

c3s4 opened this issue Jun 6, 2019 · 1 comment

Comments

@c3s4
Copy link

c3s4 commented Jun 6, 2019

As stated in the title I can't find any type definition to use this lib with typescript.
At the moment I added the

// @ts-ignore

comment before the import but it's only a workaround.
Any suggestion?

@c3s4 c3s4 changed the title Missin type definition for typescript Missing type definition for typescript Jun 6, 2019
@frncs-eu
Copy link

I'm having a look at it right now.
The most difficult part is the dynamic keys transformation, which so far is impossible with Typescript. (see https://github.com/microsoft/TypeScript/issues/12754).

We've come up with a custom .d.ts and something like this in our project:

interface ICreators {
	searchSlot: ISearchSlotCreator;
}

interface ITypes extends IReduxArcActionsTypes {
	SEARCH_SLOT: {
		REQUEST: 'REQUEST_MANAGEMENT_SEARCH_SLOT_REQUEST';
		RESPONSE: 'REQUEST_MANAGEMENT_SEARCH_SLOT_RESPONSE';
	};
	TEST_ACTION: 'REQUEST_MANAGEMENT_TEST_ACTION';
}

const { restBaseUrl } = API;

let { types, creators } = createActions<ITypes, ICreators>('requestManagement', {
	searchSlot: {
		url: `${restBaseUrl}`,
		method: 'get'
	},
	testAction: null
});

but it feels very clunky, scales badly and defeats the main purpose of this library (reduce boilerplate!)
So we are now experimenting with building a vscode extension to automatically generate type signatures for arc's createActions.
I'll let you know how it goes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants