Skip to content

typescriptServices.d.ts no longer works without CommonJS #1392

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

Closed
derekcicerone-zz opened this issue Dec 6, 2014 · 8 comments
Closed

typescriptServices.d.ts no longer works without CommonJS #1392

derekcicerone-zz opened this issue Dec 6, 2014 · 8 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@derekcicerone-zz
Copy link

I'm attempting to update the TypeScript language services from master but I'm hitting errors that look like this:

Cannot find name 'ts'.

It looks like this is being caused by this new line in typescriptServices.d.ts:

export = ts;

If I remove this line, references like "ts.Classifier" work once again. With it, I'm not able to reference the classifier either with or without the "ts." prefix. Is there another way to reference things like the classifier that I should use instead?

@DickvdBrink
Copy link
Contributor

The code below seems to work (I did it in a file called test.ts) and compiled it with
node tsc test.ts typescriptServices.d.ts --module commonjs

import ts = require("./typescriptServices");
console.log(ts);

var languageService: ts.LanguageService = null;

Hope it helps! :)

edit:
var x: ts.Classifier works too that's what I meant in my example above.

@derekcicerone-zz
Copy link
Author

Is that based on compiling the very latest code in the master branch? (not the LKG)

@derekcicerone-zz
Copy link
Author

@derekcicerone-zz
Copy link
Author

Ok, I think I see what you mean now - this works with CommonJS modules. Hmm, my code isn't currently using CommonJS though - perhaps CommonsJS is now required?

@derekcicerone-zz derekcicerone-zz changed the title Trouble using typescriptServices.d.ts after recent change typescriptServices.d.ts no longer work without CommonJS Dec 6, 2014
@derekcicerone-zz derekcicerone-zz changed the title typescriptServices.d.ts no longer work without CommonJS typescriptServices.d.ts no longer works without CommonJS Dec 6, 2014
@DickvdBrink
Copy link
Contributor

My example is with the latest master (98750ca).

From what I see in the bridge Gruntfile.js, you are concattening the typescript code with your own code, so you don't want to "require" the file. In that case It might be easier to just remove the export.

Another way:
Use the import like I had and run browserify test.js -o bundle.js to bundle everything in one file which allows you to use the latest code, still having everything in one file.

@derekcicerone-zz
Copy link
Author

Cool, thanks for the suggestions (the browserify idea is really cool!). I'll definitely do one of those options if its intentional to no longer support consumption of the definition file without using modules.

@mhegazy mhegazy added this to the TypeScript 1.4 milestone Dec 7, 2014
@mhegazy mhegazy added the Bug A bug in TypeScript label Dec 7, 2014
@DanielRosenwasser
Copy link
Member

Should be fixed in #1417. We'll be bringing that into master shortly.

@DanielRosenwasser DanielRosenwasser added the Fixed A PR has been merged for this issue label Dec 11, 2014
@derekcicerone-zz
Copy link
Author

The new typescriptServices.d.ts file is great! Looks like a lot of stuff was cleaned up and some comments were added - thanks!

@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

4 participants