locize / xliff

xliff2js and js2xliff converter xliff utils
MIT License
80 stars 37 forks source link

Could not find a declaration file for module 'xliff'. #38

Closed NagaSainath closed 3 years ago

NagaSainath commented 3 years ago

👉 Please follow one of these issue templates 👈

You have already researched for similar issues? Yes

It's not uncommon that somebody already opened an issue or in best case it's already fixed but not merged. That's the reason why you should search at first before submitting a new one. Search also on StackOverflow or similar.

Are you sure this is an issue with locize?

Yes import xliff from 'xliff' import xliff2js from 'xliff/xliff2js'

I can't do anyone of these, can anyone help me on this? is this still working? Appreciate your help Issues should only be posted in this repository after you have been able to reproduce them and confirm that they are a bug or incorrect/missing information in the docs.

Maybe your issue is more related to i18next.com, if so please open an issue here.

adrai commented 3 years ago

Please provide more information... don't know what you're trying to do

NagaSainath commented 3 years ago

@adrai Thanks for the quick response. I installed npm xliff version 5.5.2. When I tried to import xliff from 'xliff' or import xliff2js from 'xliff/xliff2js' I get "Could not find a declaration file for module 'xliff'" error on my typescript file. I'm not sure if xliff2js is exports to use?

adrai commented 3 years ago

Sorry, not a TypeScript user... can you provide a reproducible example?

import xliff from 'xliff'
xliff.xliff2js(xml, (err, res) => {})
NagaSainath commented 3 years ago

@adrai I was trying to use this example approach https://developapa.com/angular-localize/

adrai commented 3 years ago

You probably need to tweak your tsconfig or something like that, because xliff has no types at all.

adrai commented 3 years ago

This may help: https://amandeepkochhar.medium.com/typescript-error-could-not-find-a-declaration-file-for-module-xyz-dfbe6e45c2bd

NagaSainath commented 3 years ago

@adrai Thank you very much. that helped

jattasNI commented 2 years ago

In case someone else stumbles across this issue, here's an xliff.d.ts file I've used in a TypeScript project that depends on xliff. It'd be great if a more complete type declaration were available as part of the library or on DefinitelyTyped, but adding this file was all my app needed.

declare module 'xliff' {
    export type XliffTranslationString = string;

    export interface XliffTranslationObject {
        readonly 'Standalone': {
            readonly 'id': string,
            readonly 'equiv-text': string
        };
    }

    export type XliffTranslationArray = readonly (XliffTranslationString | XliffTranslationObject)[];

    export interface XliffFile {
        readonly sourceLanguage: string;
        readonly targetLanguage: string;
        readonly resources: {
            readonly 'ng2.template': {
                readonly [translationId: string]: {
                    readonly source: XliffTranslationString | XliffTranslationObject | XliffTranslationArray,
                    readonly target: XliffTranslationString | XliffTranslationObject | XliffTranslationArray
                }
            }
        };
    }

    function xliff12ToJs(contents: string): Promise<XliffFile>;
}

Credit to this repo for most of the code.

tayambamwanza commented 2 years ago

I believe this should be re-opened.

Typescript is now a commonly used tool for javascript projects, the current solution in this issue is to effectively turn off an important feature that makes projects safer (no undefined types), if possible please may this project provide proper typescript support.

adrai commented 2 years ago

It's open source... Feel free to start a pull request to contribute.