loco-cli icon indicating copy to clipboard operation
loco-cli copied to clipboard

Improve types

Open giammyisjammy opened this issue 1 year ago • 1 comments

I've noticed this while writing my .locorc.ts:

import dotenv from 'dotenv'
import { Config } from 'loco-cli/types'

dotenv.config({ path: ['.env.local', '.env'] })

export const config: Config = { // <-- type raises TS error
  accessKey: process.env.LOCO_ACCESS_KEY as string,
  localesDir: 'src/management/i18n',
  namespaces: false,
  push: {
    'flag-new': 'provisional',
    'tag-new': process.env.npm_package_version,
    'delete-absent': false,
  },
}

export default config
Type '{ accessKey: string; localesDir: string; namespaces: false; push: { 'flag-new': string; 'tag-new': string | undefined; 'delete-absent': false; }; }' is missing the following properties from type 'Config': defaultLanguage, pullts(2739)

The config is copy pasted from documentation, I've only added types to the object and moved the Loco key to an .env file for project constraints.

But defaultLanguage is deprecated and both PushOptions and PullOptions have only optional keys. So it makes sense to make their respective keys in Config optional.

What do you think?

giammyisjammy avatar Jul 25 '24 08:07 giammyisjammy

Looks good to me, what do you think @robrechtme ?

VNDRN avatar Sep 09 '24 08:09 VNDRN

Thanks for your contribution! This is now available in v3.2.0 🚀

robrechtme avatar Nov 13 '24 16:11 robrechtme