0

I build NativeScript project with TypeScript

In my module as this code,

but I get the error of "TS2306: file is not a module.",

Is any problem of setup?

models/version/version-common.ts

export function version() {

}

models/version/version.d.ts

declare module "models/version" {
    export function getVersion();

    export class version {

    }
}

models/version/version.ios.ts

import common = require("./version");

global.moduleMerge(common, exports);
export function getVersion() {
    console.log("go iOS");
}

models/version/version.android.ts

import common = require("./version");

global.moduleMerge(common, exports);
export function getVersion() {
    console.log("go android");
}

This is my folder structure.

enter image description here

1 Answer 1

1

From what I see the problem is with this import:

import common = require("./version");

In order to import your common you should change it in both ios and android files to:

import common = require("./version-common");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.