-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Add seamless-immutable type definition file #11717
Conversation
seamless-immutable/seamless.d.ts Checklist
|
@@ -0,0 +1,83 @@ | |||
// Type definitions for Seamless-immutable 6.1.3 | |||
// Project: https://github.com/rtfeldman/seamless-immutable |
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.
the file name should be seamless-immutable\seamless-immutable.d.ts
// Definitions by: alex3165 <https://github.com/alex3165> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
|
||
// Copyright (c) 2016, Richard Feldman |
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.
For legal reasons, we can not have different licence text for packages. all packages use the MIT licence under: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/LICENSE
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.
So we will not be able to accept this PR as long as it has this specialized licence text.
merge(part: any, config?: MergeConfig): ImmutableObject<T>; | ||
|
||
update(property: string, updaterFunction: (value: any) => any): ImmutableObject<T>; | ||
update(property: string, updaterFunction: (value: any, additionalParameter1: any) => any, arg1: any): ImmutableObject<T>; |
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 would recommend changing these into one signature with rest args:
update(property: string, updaterFunction: (value: any, ...additionalParamters: any[]) => any, ...additionalArguments: any[]): ImmutableObject<T>;
updateIn(propertyPath: Array<string>, updaterFunction: (value: any, additionalParameter1: any, additionalParameter2: any, additionalParameter3: any) => any, arg1: any, arg2: any, arg3: any): ImmutableObject<T>; | ||
updateIn(propertyPath: Array<string>, updaterFunction: (value: any, additionalParameter1: any, additionalParameter2: any, additionalParameter3: any, additionalParameter4: any) => any, arg1: any, arg2: any, arg3: any): ImmutableObject<T>; | ||
|
||
without(property: string): ImmutableObject<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.
this is already covered by without(...properties: string[]): ImmutableObject<any>;
@mhegazy Thank you for your advice I have made the changes. |
thanks. can you please address the failing CI tests. |
@mhegazy Fixed |
Anyone have an example app using this w/ TS 2x ? Just looking around for some samples to see how you would import and use use something like note: mostly asking because I ran into this error building a TS 2.1 app using this type def import Immutable from 'seamless-immutable';
const initialState = Immutable({
});
UPDATE I was able to get this working by altering my import like so import * as SI from 'seamless-immutable';
const initialState = SI.from({
}); My first pass at typescript + seamless immutable (along with redux/and emberJS) for those who may find this later. I had to do an interesting hack to get this working (note this toward the top of the file) toranb/ember-redux-yelp@0fe9bfa import * as SI from 'seamless-immutable';
const Immutable = SI['default'] ? SI['default'] : SI;
const initialState = Immutable({
}); UPDATE July 2017 I ended up writing a set of type defs for seamless-immutable 7 https://github.com/toranb/seamless-immutable-tsdefs I've had success writing product types like you see below import { ImmutableObject } from 'seamless-immutable';
type ImmutableState<T> = ImmutableObject<T> & T;
export default ((state: ImmutableState<UserState>, action: Action): ImmutableState<UserState> => {
switch(action.type) {
case 'ASSIGN_USER': {
return state.merge({number: action.number});
}
default: {
return state || initialState;
}
}
}); |
case 1. Add a new type definition.
--target es6
and--noImplicitAny
options.-tests.ts
or-tests.tsx
.case 2. Improvement to existing type definition.