I'm trying to type a default external class from t...
# javascript
g
I'm trying to type a default external class from the "values.js" npm module and it always responds with:
Uncaught TypeError: Values_0 is not a constructor
. The original code can be seen here: https://github.com/noeldelgado/values.js/blob/master/src/index.js. I've used this in the kt file:
Copy code
@file:JsModule("values.js")
@file:JsNonModule

@JsName("default")
external class Values(color: String = definedExternally, type: String = definedExternally, weight: Int = definedExternally)
Is this a problem with the module itself or how I'm defining the kotlin class?
t
It depends on final module type
What about this?
Copy code
@JsModule("values.js")
external class Values(color: String = definedExternally, type: String = definedExternally, weight: Int = definedExternally)
g
I've included the node modules file structure and the project is umd so it needs a
@JsNonModule
apparently.
Copy code
@JsModule("values.js")
@JsNonModule
@JsName("default")
external class Values(color: String = definedExternally, type: String = definedExternally, weight: Int = definedExternally)
This produces another error message:
Uncaught Error: Module parse failed: Unexpected token (9:16)
File was processed with these loaders:
* ../../node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
|     if (typeof mix === 'undefined') {
|       throw new Error("Error loading module 'compose-web-big-table-color-generator'. Its dependency 'mix-css-color' was not found. Please, check whether 'mix-css-color' is loaded prior to 'compose-web-big-table-color-generator'.");
>     }if (typeof default === 'undefined') {
|       throw new Error("Error loading module 'compose-web-big-table-color-generator'. Its dependency 'values.js' was not found. Please, check whether 'values.js' is loaded prior to 'compose-web-big-table-color-generator'.");
|     }root['compose-web-big-table-color-generator'] = factory(typeof this['compose-web-big-table-color-generator'] === 'undefined' ? {} : this['compose-web-big-table-color-generator'], mix, default);
at eval (webpack-internal:///./kotlin/compose-web-big-table-color-generator.js:1)
at Object../kotlin/compose-web-big-table-color-generator.js (color-generator.js:482)
at __webpack_require__ (color-generator.js:30)
at Object.0 (color-generator.js:494)
at __webpack_require__ (color-generator.js:30)
at color-generator.js:94
at color-generator.js:97
at webpackUniversalModuleDefinition (color-generator.js:9)
at color-generator.js:10
t
Does it work for
commonjs
module kind?
g
yeah commonjs and the cdn versions worked, I'm not too sure why the umd didn't though