Skip to content

Typescript ignores typings when using tsconfig.json paths #17583

Closed
@WoMayr

Description

@WoMayr

TypeScript Version: 2.3.4, 2.4.2, 2.5.0-dev.20170801

fabric@1.7.17 and @types/fabric are installed.

Code

tsconfig.json

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "baseUrl": "src/",
        "sourceMap": true,
        "outDir": "dist/out-tsc",
        "paths": {
            "fabric": [ "../node_modules/fabric/dist/fabric.require.js" ]
        }
    },
    "exclude": [
        "node_modules"
    ],
    "compileOnSave": false
}

src/app.ts

import * as fabric from "fabric";

window.addEventListener("load", function () {
    const canvas = new fabric.Canvas("my-canvas");

    // create a rectangle object
    var rect = new fabric.Rect({
        left: 100,
        top: 100,
        fill: "red",
        width: 20,
        height: 20,
        lockUniScaling: true
    });

    // "add" rectangle onto canvas
    canvas.add(rect);

    // canvas.toSVG() is faulty inside definitions
    console.log(canvas.toSVG());
});

Expected behavior:
TSC should report an error that toSVG needs parameters.

Actual behavior:
typescript doesn't load any type definitions for the fabric module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions