Skip to content

import when there is no module (for SystemJS side effects) #4602

Closed
@myitcv

Description

@myitcv

Apologies if this is a duplicate of an existing issue, but I haven't been able to find an answer to this specific issue. I note however #2839

A summary of the config/setup for our app:

  • TypeScript v1.7.0-dev.20150827
  • tsd v0.6.4-beta
  • tsconfig.json:
{
  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "declaration": false,
    "noImplicitAny": true,
    "removeComments": false,
    "noLib": false,
    "sourceMap": true,
    "jsx": "react"
  }
}

Our app depends on bootstrap-slider; as you can see this type definition does not define a module. Instead it 'extends' jquery in what I understand is the usual way for JQuery components. Via tsd our app defines a tsd.d.ts file that references the bootstrap-slider and jquery type definitions, amongst others.

Now consider a .tsx file where we define a React component that wraps bootstrap-slider. This .tsx file references the tsd.d.ts definition.

jquery declares $, hence there is no need to import jquery. Nor is there a need to import bootstrap-slider from a typing perspective because we will reference everything we need via jquery's $ (indeed to try and do so would fail because there is no module by the name of "bootstrap-slider" defined)

However, this now presents a problem because nowhere in our application are we declaring via an import a dependency on bootstrap-slider. The generated code (target ES5, module SystemJS) does not include a reference to bootstrap-slider and hence the relevant JS files are not loaded at runtime.

What is the recommended solution in this situation?
Should the bootstrap-slider type definition include a module definition for exactly this reason?
Or are we missing a more obvious solution?

Thanks

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