Skip to content

Releases: seek-oss/vocab

@vocab/[email protected]

14 Mar 03:01
09eded4
Compare
Choose a tag to compare

Patch Changes

@vocab/[email protected]

06 Mar 23:51
522ca5e
Compare
Choose a tag to compare

Minor Changes

  • fa1d81f #121 Thanks @askoufis! - Add StringWithSuggestions utility type

    This type is equivalent to the string type, but it tricks the language server into providing suggestions for string literals passed into the Suggestions generic parameter.

    EXAMPLE USAGE:

    type AnyAnimal = StringWithSuggestions<'cat' | 'dog'>;
    // Suggests cat and dog, but accepts any string
    const animal: AnyAnimal = '';

@vocab/[email protected]

06 Mar 23:51
522ca5e
Compare
Choose a tag to compare

Patch Changes

  • fa1d81f #121 Thanks @askoufis! - Add StringWithSuggestions utility type

    This type is equivalent to the string type, but it tricks the language server into providing suggestions for string literals passed into the Suggestions generic parameter.

    EXAMPLE USAGE:

    type AnyAnimal = StringWithSuggestions<'cat' | 'dog'>;
    // Suggests cat and dog, but accepts any string
    const animal: AnyAnimal = '';
  • Updated dependencies [fa1d81f]:

@vocab/[email protected]

06 Mar 23:15
467e08b
Compare
Choose a tag to compare

Patch Changes

  • ec718fe #119 Thanks @askoufis! - Fix compiled type for select parameter

    Vocab uses intl-messageformat to parse and derive types for ICU translation messages.
    By default this parser enforces that select (and plural) arguments must contain an other clause as a fallthrough.
    Vocab does not deviate from this default, but it was previously deriving the type of select type arguments as a string literal union of all possible match cases:

    {
      "My message": {
        "message": "{param, select, foo {foo} bar {bar} other {baz}}"
      }
    }
    // Type Error: `param` is not of type 'foo' | 'bar' | 'other'
    t('My message', { param: 'something else' });

    This is incorrect, as the other clause is a fallthrough for values other than foo or bar.
    Vocab will now derive the type of these arguments as StringWithSuggestions<Suggestions>.
    This type is equivalent to string, but it enables your IDE to provide suggestions for explicit matches.

    // `param` can be any string, but "foo" and "bar" will be suggested
    t('My message', { param: '' });

@vocab/[email protected]

02 Mar 22:08
7cf5e49
Compare
Choose a tag to compare

Patch Changes

  • 673b16c #117 Thanks @askoufis! - Deeply parse nested arguments inside plural arguments

    ICU plural type arguments can contain arguments in their matches:

    {
      "My message": {
        "message": "{numThings, plural, one {{foo} singular} other {{bar} plural}}"
      }
    }

    These were being parsed incorrectly, resulting in only the top-level plural argument being output in the compiled message type:

    // Type error: `foo` and `bar` are not valid arguments
    t('My message', { numThings: 1, foo: 'foo', bar: 'bar' });

    These arguments are now correctly parsed resulting in a correctly typed message:

    // Works!
    t('My message', { numThings: 1, foo: 'foo', bar: 'bar' });

@vocab/[email protected]

01 Mar 23:49
0eb024c
Compare
Choose a tag to compare

Patch Changes

  • c3c5a05 #104 Thanks @askoufis! - Remove dependency on json-loader, resolve virtual-resource-loader before using it in the vocab loader

[email protected]

13 Feb 03:25
9f03d18
Compare
Choose a tag to compare

Patch Changes

@vocab/[email protected]

13 Feb 03:25
9f03d18
Compare
Choose a tag to compare

Patch Changes

@vocab/[email protected]

13 Feb 03:25
9f03d18
Compare
Choose a tag to compare

Patch Changes

@vocab/[email protected]

13 Feb 03:25
9f03d18
Compare
Choose a tag to compare

Patch Changes