Jump to content
Search Community

Can't import GSAP 3 with TypeScript

focomoso test
Moderator Tag

Recommended Posts

Hi,

 

I'm new to GSAP and the forum. I'm evaluating GSAP for use in an internal charting app and am having trouble getting it to import into a skeleton typeScript project. In empty typeScript project with gsap 3.0.1 installed, the line 

import gsap from "gsap";

 

Is causing a webpack warning "System.register is not supported by webpack" and the browser to give "index.tsx:1 Uncaught TypeError: (void 0) is not a function". I've tried many varients, including import { gsap } from "gsap";import * as gsap from "gsap"; and import "gsap";

 

Also, VS Code gives a "Cannot find module 'gsap'. warning if I don't also install the @types (which, I understand, shouldn't be necessary with gsap 3).

 

Here's my webpack.config.js if it helps:

 

const path = require("path");
 
module.exports = {
  resolve: {
    extensions: ['.ts', '.tsx', '.js'],
  },
  entry: "./src/index.tsx",
  output: {
    filename: "bundle.js",
    path: path.resolve(__dirname, "dist"),
    publicPath: "/dist/"
},
  module: {
    rules: [
      { test: /\.tsx?$/, loader: "ts-loader" },
    ]
  },
  devServer: {
    stats: {
      assets: false,
      hash: false,
      chunks: false,
      errors: true,
      errorDetails: true,
      },
    overlay: true,
    port: 3333
  }
};

 

Any help re where I should be looking would be appreciated.

 

Thanks

 

 

Link to comment
Share on other sites

9 minutes ago, focomoso said:

Also, VS Code gives a "Cannot find module 'gsap'. warning if I don't also install the @types (which, I understand, shouldn't be necessary with gsap 3).

 

You don't. Installing @types will give you the wrong ones. 

 

Can you make a simple repo showing the problem. It's very hard to troubleshoot blind.

  • Like 2
Link to comment
Share on other sites

2 minutes ago, focomoso said:

Thanks for the quick reply. It turns out it was an issue with my tsconfig

 

Yeah, that's what it sounded like. Nobody really uses system anymore.

 

2 minutes ago, focomoso said:

It's working well now (without the @types). 

 

Note that the types for the latest release are a little incomplete. Most issues should be fixed in the next release. If you run into errors, just let me know, I can tell you how to silence them.

  • Like 3
Link to comment
Share on other sites

25 minutes ago, OSUblake said:

 

Yeah, that's what it sounded like. Nobody really uses system anymore.

That's what you get for using old boilerplate...

 

Quote

Note that the types for the latest release are a little incomplete. Most issues should be fixed in the next release. If you run into errors, just let me know, I can tell you how to silence them.

Will do, thanks. 

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...