Understanding internal/external modules and import/require Typescript 0.8.2

前端 未结 1 1302
走了就别回头了
走了就别回头了 2021-02-06 04:46

There are numerous StackOverflow questions that touch on this subject, but either aren\'t quite the same as what I\'m attempting, or are for previous versions of TypeScript.

相关标签:
1条回答
  • 2021-02-06 05:03

    This is what I make of your situation.

    Your modules...

    You need to name your file after your module, so a.ts, should actually be m.ts and should contain something like...

    import express = module('express');
    
    export class a {
        A: b;
        A2: express.ServerResponse;
    }
    
    export class b {
        B: number;
    }
    

    You shouldn't be using reference statements here.

    When you are running code on nodejs, you can't really split your code across multiple files because the file itself is your module - when you import m = module('m'); it will look for m.js. What you can do is organise your files in a folder structure.

    import x = module('m/x'); // m/x.js
    import y = module('m/y'); // m/y.js
    
    0 讨论(0)
提交回复
热议问题