question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

no locale available in typescript, cannot be used

See original GitHub issue

Package.json

"react-json-editor-ajrm": "^2.5.13",
"@types/react-json-editor-ajrm": "^2.5.1",

Usage

import React from 'react';
import JSONInput from 'react-json-editor-ajrm';
import locale from 'react-json-editor-ajrm/locale/en'; // this does not exist in typescript, compilation fails 

export interface Props {
    data: Record<string, unknown>;
    onSaveClick: () => void;
}

export default function Configs(p: Props): React.ReactElement<Props> {
    return (
        <div>
            <JSONInput id="a_unique_id" placeholder={{}} theme={'darktheme'} locale={locale} height="550px" />
        </div>
    );
}

TS7016: Could not find a declaration file for module 'react-json-editor-ajrm/locale/en'. 

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:11
  • Comments:6

github_iconTop GitHub Comments

2reactions
dsalgadorcommented, Sep 16, 2021

Same problem here.

"react-json-editor-ajrm": "^2.5.13",
"@types/react-json-editor-ajrm": "^2.5.2",

image

Edit

I have found a workaround which consists on copying the constants in the path react-json-editor-ajrm/locale/XX.js, where XX are the available languages (de, en, es, …) and storing it in a constant variable which is then used as argument of the JSONInput component:

const locale = {
    format: "{reason} at line {line}",
    symbols: {
        colon: "colon",
        // :
        comma: "comma",
        // ,  ،  、
        semicolon: "semicolon",
        // ;
        slash: "slash",
        // /  relevant for comment syntax support
        backslash: "backslash",
        // \  relevant for escaping character
        brackets: {
            round: "round brackets",
            // ( )
            square: "square brackets",
            // [ ]
            curly: "curly brackets",
            // { }
            angle: "angle brackets", // < >
        },
        period: "period",
......
.......
........}


 <JSONInput
    id="a_unique_id"
    placeholder={sampleData}
    height="550px"
    locale={locale}
/>

Hope this helps to someonelse.

0reactions
yoyoscommented, Jun 2, 2022

thanks for the trick dsalgador

Read more comments on GitHub >

github_iconTop Results From Across the Web

The locale to use to show error messages in TypeScript in ...
This works in terminal: tsc --locale "cs" error TS2322: Typ 6 nejde přiřadit typu string. But not directly in VS Code: Value "cs"...
Read more >
Components | Format.JS
This allows configuration like the current locale and set of translated strings/messages to be provided at the root of a component tree and...
Read more >
Intl.Locale - JavaScript - MDN Web Docs
Chrome Edge Locale Full support. Chrome74. Toggle history Full support. Edge79. Toggle hi... Locale() constructor Full support. Chrome74. Toggle history Full support. Edge79. Toggle hi... baseName...
Read more >
next-i18next - npm
TypeScript icon, indicating that this package has built-in type declarations ... There is only one exception: You can not use a function for ......
Read more >
Documentation - Module Resolution - TypeScript
Finally, if the compiler could not resolve the module, it will log an error. ... Note: node module resolution is the most-commonly used...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found