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

Can't import typescriptServices under node moduleResolution #5264

Closed
Gaelan opened this issue Oct 15, 2015 · 8 comments
Closed

Can't import typescriptServices under node moduleResolution #5264

Gaelan opened this issue Oct 15, 2015 · 8 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@Gaelan
Copy link

Gaelan commented Oct 15, 2015

Exported external package typings file '[app-root]/node_modules/typescript/lib/typescriptServices.d.ts' is not a module. Please contact the package author to update the package definition.

I'm not sure how we should handle this.

@basarat
Copy link
Contributor

basarat commented Oct 15, 2015

Temporary workaround I've been using:

  • ntypescript exports to global anyways ... so just /// <reference path="../../node_modules/ntypescript/bin/ntypescript.d.ts"/> it manually (works with exclude too) and then have a single var/require call to get the runtime semantics to match compile time inference (global)

Would love to see a proper fix / discussion 🌹

@mhegazy
Copy link
Contributor

mhegazy commented Oct 15, 2015

you should not import typescriptServices.js, this is a file you would include in a webpage for instance. use typescript.js if you want to import it. simply use import * as ts from "typescript" and no need for the /// <reference

@mhegazy mhegazy added the Question An issue which isn't directly actionable in code label Oct 15, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Oct 15, 2015

Would love to see a proper fix / discussion

@basarat i am not sure i understand the issue here.. can you elaborate?

@Gaelan
Copy link
Author

Gaelan commented Oct 15, 2015

@basarat I used this:

/// <reference path='../node_modules/typescript/lib/typescriptServices' />
var TypeScript = require('typescript/lib/typescriptServices') as typeof ts

This lets me use plain TS.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 15, 2015

@Gaelan so why is not import * as TypeScript from 'typescript'); working for you?

@Gaelan
Copy link
Author

Gaelan commented Oct 15, 2015

@mhegazy Weird timing. I started a reply to @basarat's comment, you commented, then I clicked Comment.

@basarat
Copy link
Contributor

basarat commented Oct 15, 2015

you should not import typescriptServices.js, this is a file you would include in a webpage for instance. use typescript.js if you want to import it. simply use import * as ts from "typescript" and no need for the /// <reference

Got it 👍 . NTypeScript needs an update. require('typescript') works fine.

@basarat
Copy link
Contributor

basarat commented Oct 15, 2015

For reference : I had a single def file that exported both a module name + global. But I guess I will need to split them into two def files (like typescript does).

@mhegazy mhegazy closed this as completed Nov 13, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

3 participants