Midwest Dev Chat

MidwestDevChat.com

  • The newest 15 messages in the super-cool #typescript channel.

  • 03/16 11:11:53 Jeniffer: maybe I’ll try to update the version of Dojo they use and if that works submit a PR… heh
  • 03/16 11:38:32 Jeniffer: blech. can’t even get local version of dojo to install
  • 03/16 11:38:34 Jeniffer: disappointed
  • 03/20 16:38:20 Shyla: @Shyla uploaded a file: Private image uploaded, members only. Sorry.
  • 03/27 11:45:14 Shyla: https://twitter.com/typescriptlang/status/97867...
  • 04/09 09:56:53 Jeniffer: not exactly typescript, but it is tangential because of the command contents… I’m not great at bash so forcing myself to build commands like this and succeeding makes me happy: `$ for p in $(cat package.json | grep @types | cut -d \" -f 2); do npm i -D $p@latest; done`
  • 04/10 09:56:42 Jeniffer: hey so intersection types are not behaving like I think I want them to…
  • 04/10 09:58:09 Jeniffer: if I do this:
    export type PartialStateType = CompanyState | DevicesState
    	| HealthReportState | MediaState | PlaylistState
    	| RolesState | UIState | UploadsState | UserState;
    
    export function defaultState(state: PartialStateType, ctor: StateConstructor<PartialStateType>) {
    	const newState = new ctor();
    
    	return Object.assign({}, newState, state);
    }
    ```
    then call it in another module like `return defaultState(state, UploadsState);`, I get the following error:
    ```
    1 src/Data/Reducers/Upload.ts|36 col 4 error| 2322[QF available]: Type 'PartialStateType' is not assignable to type 'UploadsState'. Type
        ↪'CompanyState' is not assignable to type 'UploadsState'. Property 'uploads' is missing in type 'CompanyState'.¬
    
  • 04/10 09:59:37 Jeniffer: anybody know a thing that might assist with this? each of the *State classes has a different shape. I would love to be able to pass a state that is one of them to this function and type it as something other than `any`
  • 04/10 10:00:18 Jeniffer: as a generic, it doesn’t complain — there’s no problem with my `StateConstructor` interface, but as the type of a variable it is not working so nicely
  • 04/10 10:30:05 Jeniffer: woo ended up changing the signature of `defaultState`
  • 04/10 10:30:10 Jeniffer: `export function defaultState<T>(state: T, ctor: StateConstructor<T>)`
  • 04/10 10:30:27 Jeniffer: then I just pass in the Class I want instead of having an intersection type
  • 04/18 14:55:47 Shyla: I interviewed the TypeScript team last month at TSConf! https://vimeo.com/265419087
  • *Usernames have been changed to protect the innocent.
We're currently 1048 members strong. Join us!
Request Invite

Check out all the cool channels!

Join the conversation!