yoga-layout-wasm icon indicating copy to clipboard operation
yoga-layout-wasm copied to clipboard

error TS1046: Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier

Open AndriiNeverov opened this issue 4 years ago • 1 comments

I'm trying to include this module into an Ionic app and get the following on ionic serve:

[ng] ERROR in node_modules/yoga-layout-wasm/index.d.ts:26:1 - error TS1046: Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier.
[ng] 26 const mod: YogaWasm

I have:

"yoga-layout": "^1.9.3", "yoga-layout-wasm": "^1.9.3-alpha.7", "@types/yoga-layout": "^1.9.2",

NOTE: also there is another error, but that one can be at least solved by setting:

"compilerOptions": {
    "allowSyntheticDefaultImports": true,
[ng] ERROR in node_modules/yoga-layout-wasm/index.d.ts:1:8 - error TS1259: Module '"/priv/src/Startup/Embedded/hello1/node_modules/@types/yoga-layout/index"' can only be default-imported using the 'allowSyntheticDefaultImports' flag
[ng] 1 import Yoga from "yoga-layout";
[ng]          ~~~~
[ng]   node_modules/@types/yoga-layout/index.d.ts:413:1
[ng]     413 export = Yoga;
[ng]         ~~~~~~~~~~~~~~
[ng]     This module is declared with using 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag.

AndriiNeverov avatar Jul 01 '20 01:07 AndriiNeverov

This is because CommonJS modules are being created, instead of ESM. Change in your rollup.config.js format from cjs to esm, then execute npm run build

VaskillerDev avatar Oct 11 '21 16:10 VaskillerDev