Typescript 将直接ES6模块从索引传递到TypesScript应用程序

Typescript 将直接ES6模块从索引传递到TypesScript应用程序,typescript,systemjs,es6-module-loader,Typescript,Systemjs,Es6 Module Loader,我想将服务器端呈现的配置作为ES6模块传递给一个可以导入的TypeScript应用程序。使用SystemJS模块加载器 配置模块直接在index.html中设置: System.set(System.normalizeSync('config'), System.newModule({ foo: 'bar' })); // in the real scenario the { foo: 'bar' } is rendered by the server 然后在main.ts import {

我想将服务器端呈现的配置作为ES6模块传递给一个可以导入的TypeScript应用程序。使用SystemJS模块加载器

配置模块直接在index.html中设置:

System.set(System.normalizeSync('config'), System.newModule({ foo: 'bar' })); // in the real scenario the { foo: 'bar' } is rendered by the server
然后在main.ts

import { foo } from 'config';
这在浏览器中起作用,因为SystemJS识别配置模块,但TypeScript编译器会抱怨:

找不到模块'config'


如何告诉TypeScript index.html中定义的“外部”自定义模块

如果
config
不是typescript模块(没有类型定义等),则不能像这样导入它(它看起来像ES6导入,但实际上不是一个)。因此,要么为它编写
d.ts
文件,并将它放在
tsc
可以找到它的地方,要么尝试使用
let config=require('config')
以某种“自由形式”导入它。然后您可以使用它,但不需要任何类型提示和检查。

哪里适合使用“allowjs”指令?