Typescript es6 import module “File is not a module error”

后端 未结 6 1763
日久生厌
日久生厌 2020-12-02 07:37

I am using typescript 1.6 with es6 modules syntax.

My files are:

test.ts:

module App {
  export class SomeClass {
    getNam         


        
6条回答
  •  星月不相逢
    2020-12-02 08:21

    In addition to Tim's answer, this issue occurred for me when I was splitting up a refactoring a file, splitting it up into their own files.

    VSCode, for some reason, indented parts of my [class] code, which caused this issue. This was hard to notice at first, but after I realised the code was indented, I formatted the code and the issue disappeared.

    for example, everything after the first line of the Class definition was auto-indented during the paste.

    export class MyClass extends Something {
        public blah: string = null;
    
        constructor() { ... }
      }
    

提交回复
热议问题