Skip to content

ftl2js throws null error when message has only attributes #6

Description

@tustin2121

🐛 Bug Report

The ftl2js function throws a TypeError for trying to "read properties of null" when a message has attributes but no pattern.

To Reproduce

let ftl = `
app = 
  .name = Hello
`;

let data = ftl2js(ftl);

The problem seems to be that the getTypeName function simply assumes that it will be passed a valid object and does no checks for null, and a message with no pattern parses to a null value. Having a message with no pattern but one or more attributes is valid fluent syntax.

Expected behavior

An exception is not thrown.

Your Environment

  • runtime version: Electron v30.0.1, Node v20.11.1
  • module version: fluent_conv: 3.3.0
  • os: Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions