System js map doesn't work

泄露秘密 提交于 2020-01-06 16:24:02

问题


Maybe I am dumb but system js always gives so much pain, although its so nice that I don't want to use anything else.

My system js config is this:

System.config({
        packages: {
            app: {
                format: 'register',
                defaultExtension: 'js'
            },
            primeng:{
                format: 'register',
                defaultExtension: 'js'
            }
        },
        map: {
          primeng: 'node_modules/primeng'
        }
    });

Primeng is being imported like this:

import {Accordion} from "primeng/primeng";
import {AccordionTab} from "primeng/primeng";

This is a ts file which gets compiled in js by gulp and then used by my index.html.

But in my terminal I get error:

error TS2307: Cannot find module 'primeng/primeng'

If anyone has any idea, please solve this


回答1:


Figured it out.

We have to reference the type definition in the component's .ts file itself. So at the top of my component file I have to write this:

///<reference path="../../node_modules/primeng/components/accordion/accordion.d.ts"/>


来源:https://stackoverflow.com/questions/37437726/system-js-map-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!