lundi 5 octobre 2020

TypeScript: An abstract class is undefined while creating a child class (Object prototype may only be an Object or null: undefined)

I have built a framework called "tyframe" as monorepo using lerna. (https://github.com/tyframe/tyframe) Currently there are the two packages "core" and "example". The latter is indended for demonstration pruposes and works as expected.

Now I want to use the package "@tyframe/core" in a different web project without success.

The problem:

My class App inherits from the class AbstractApplication, but on runtime AbstractApplication is undefined and I get the error "Object prototype may only be an Object or null: undefined".

To demonstrate the problem and to make it understandable, I have created a minimal example on Stackblitz: https://stackblitz.com/edit/typescript-av2uka?devtoolsheight=33&file=index.ts

Is there anything else to consider when I publish my framework so that I can use it in other web projects?

Futher information:

I am using webpack to build my framework:

module.exports = {
    mode: 'development',
    devtool: 'inline-source-map',
    module: {
      rules: [
        {
          test: /\.ts$/,
          use: {
              loader: 'ts-loader',
              options: {
                  configFile: 'tsconfig.build.json',
              }
          },
          exclude: /node_modules/,
        },
      ],
    },
    resolve: {
      extensions: [ '.ts', '.js' ],
    },
  };

No errors are thrown during the compilation process.

Does anyone have an idea?




Aucun commentaire:

Enregistrer un commentaire