Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbols not found when using tsc --out #37

Open
Dynalon opened this issue Dec 8, 2013 · 3 comments
Open

Symbols not found when using tsc --out #37

Dynalon opened this issue Dec 8, 2013 · 3 comments

Comments

@Dynalon
Copy link

Dynalon commented Dec 8, 2013

I am using Grunt with grunt-typescript to invoke the tsc compiler on my *.ts files. I am using T3S for syntax highlighting within Sublime, and I found that when using the --out tsc parameter (in the tsc invoked by grunt) there is no way to tell that to T3S.

T3S will complain about not finding any types that are not in the same file. Note that when using the --out flag, all *.ts files that you pass are compiled into a single .js file. There is no import/export within my code, as the tsc compiler will automatically resolve all types that are in the list of *.ts files.

As a workaround I put the ///<reference path="..." /> into the source code, so that T3S stil works. But for the compile step to work, I wouldn't need these reference tags.

@Railk
Copy link
Owner

Railk commented Dec 8, 2013

Hello,

Do you use the dev branch or the master/ST2 branch ?
Can you tell me how you have setup your project (sublime-project file or .sublimets file)?

T3S work with a root file that is your main project file and then you import name = require("name"); as usual and it should regognize your class, var, function etc.. you've exported in the other files.

If your don't setup a project either using a .sublimets file or the sublime-project file, every file will have a separate instance of the plugin and so not "communicate" with each other.

Can you show me how you've setup your project ?

@Dynalon
Copy link
Author

Dynalon commented Dec 8, 2013

I am using master/ST2.I don't have a sublime-project or .sublimets file, which is most likely the problem.

To be clear, I don't use import or import x = require('somemod') throughout all my code (on purpose, as I don't wan't t use AMD/CommonJS modules). The basic idea of the setup is:

// file1.ts
module MyProject {
   class MyClass {
       constructor() {
            console.log('hello world');
       }
   }
}

// file2.ts
module MyProject {
   class MyOtherClass {
       constructor() {
            var x = new MyClass();
       }
   }
}

The tsc compiler will accept the above code when using tsc --out all.js file1.ts file2.ts (tested with tsc 0.9.1.1). However, T3S will fail to resolve MyClass in file2.ts. Note that import or require is not necessary, as both classes are defined within the same module (but not the same file). As I don't have a sublimets file this is maybe the cause. How can I setup the file correctly, and do I need to be on the dev branch for that?

@Railk
Copy link
Owner

Railk commented Dec 8, 2013

.sublimets

{
    "root":"file1.ts"
}

With this project organisation, right now the plugin will not add the file2.ts to the project, you need as you said in your first post to add a reference for the file to be added to the project, if we assume the fact that file1.ts is the root here and then export the class for it to be visible to the file2.ts

file1.ts

/// <reference path="file2.ts" />

module MyProject {
   export class MyClass {
       constructor() {
            console.log('hello world');
       }
   }
}

But i assume it's not the way you want this to work :), i'll add to my to do list to look at at this kind of project structure and see if i can make it work.

I cannot give a date cause i'm a busy right now, but i'll look into it :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants