s-panferov / awesome-typescript-loader

Awesome TypeScript loader for webpack
Other
2.35k stars 179 forks source link

File is not a module #553

Open JacoSmit opened 6 years ago

JacoSmit commented 6 years ago

Hi,

I am trying to import a .ts file from a .tsx file but I get the following error:

TS2306: File 'C:/development/article.ts' is not a module.

article.ts

export default class Article {
    constructor(
        private _title: string, 
        private _description: string, 
        private _author: string, 
        private _content: string[], 
        private _id: string
    ) {

    }

    get title(): string {
        return this._title;
    }

    get description(): string {
        return this._description;
    }

    get author(): string {
        return this._author;
    }

    get content(): string[] {
        return this._content;
    }

    get id(): string {
        return this._id;
    }
}

Importing in the .tsx file as:

...
import * as Article from './article';
...

Do I need to declare a typings file or should this be enough?