Skip to content

Importing untyped JS modules #3019

Closed
Closed
@jonrimmer

Description

@jonrimmer

I have been trying out the 1.5 beta, but I am confused about importing modules from 3rd-party JS libraries. As I understand it, TS is intended as a superset of JS so if, for example, I have a CommonJS library called foo.js, then in my app.ts, I should be able to do:

import foo from 'foo';

And this should be compiled (depending on my compile options) into a CommonJS require statement, which can then be consumed by Node, Browserify, etc.

This works in regular JavaScript (as compiled by Babel), but it does not work in TypeScript. I get a compiler error saying "Cannot find external module 'foo'".

I understand that I can maybe write a .ts.d file that describes this library, but what if I don't want to do this? What if I just want to import a module and use it, as I would in regular JS?

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions