Lusito / box2d.ts

Full blown Box2D Ecosystem for the web, written in TypeScript
https://lusito.github.io/box2d.ts
60 stars 6 forks source link

[Solved] b2_island.d.ts:3:10 - error TS2305: Module '"./b2_contact_solver"' has no exported member 'b2ContactVelocityConstraint'. #26

Closed 8Observer8 closed 2 years ago

8Observer8 commented 2 years ago

How to solve this problem?

image

{
    "compilerOptions": {
        "target": "ES5",
        "outDir": "../public/js",
        "sourceMap": false,
        "types": [
            "node"
        ],
        "allowSyntheticDefaultImports": true,
        "esModuleInterop": true
    },
    "include": [
        "../src/**/*.ts"
    ],
    "exclude": [
        "node_modules"
    ]
}
8Observer8 commented 2 years ago

I tried to copy all settings from the box2d.ts/tsconfig.json and compilation is okay but now Browserify cannot bundle it:

browserify public/js/main.js -o public/js/bundle.js

E:\_Projects\Physics\box2d-core\typescript-webgl-example\public\js\main.js:1
import { b2World } from "@box2d/core";
^
ParseError: 'import' and 'export' may appear only with 'sourceType: module'
{
    "compilerOptions": {
        "target": "ES2018",
        "outDir": "../public/js",
        "sourceMap": false,
        "lib": [
            "ES2018",
            "DOM"
        ],
        "types": [
            "node"
        ],
        "allowSyntheticDefaultImports": true,
        "esModuleInterop": true,
        "moduleResolution": "node",
        "declaration": true,
        "strict": true,
        "noUnusedLocals": true,
        "noImplicitReturns": true,
        "noFallthroughCasesInSwitch": true,
        "skipLibCheck": true,
        "resolveJsonModule": true,
        "declarationMap": true
    },
    "include": [
        "../src/**/*.ts"
    ],
    "exclude": [
        "node_modules"
    ]
}
8Observer8 commented 2 years ago

I solved this problem. I added only this line:

"skipLibCheck": true

It works:

{
    "compilerOptions": {
        "target": "ES5",
        "outDir": "../public/js",
        "sourceMap": false,
        "types": [
            "node"
        ],
        "allowSyntheticDefaultImports": true,
        "esModuleInterop": true,
        "skipLibCheck": true
    },
    "include": [
        "../src/**/*.ts"
    ],
    "exclude": [
        "node_modules"
    ]
}
Lusito commented 2 years ago

Yes, skipLibCheck is the quick-fix. I'll check if I can fix this without the user needing to add this flag.

Lusito commented 2 years ago

I have just released a new version, which should fix the issues. Can you try again without skipLibCheck?

8Observer8 commented 2 years ago

Yes, 0.9.2 works without skipLibCheck

Lusito commented 2 years ago

Thanks for checking.