当我在TypeScript节点样式库中声明,定义和使用函数时,然后使用来自例如一个角度项目,代码在浏览器中失败,声称函数未定义。
当我也直接从使用库的代码中使用它时,它包含在结果包中。
但是,如果我不这样做,它会从包中丢失,从而导致此错误。
有没有办法在库中声明内部使用的函数很重要并且应该包含在bundle中?
使函数成为类的静态方法并不起作用,因为我需要转发声明它以避免循环依赖,这对于静态方法是不可能的。
里面的函数" superclassDeserialization.ts":
export function createDesktopToCompanionEventFromStream(stream: InputStream): DesktopToCompanionEvent
{
let subtypeId = Serializer.readSubtypeId(stream);
switch(subtypeId)
{
case 1:
return CodePointDesktopToCompanionEvent.createFromStreamAfterIdentification(stream);
default:
throw new RangeError("Unknown subtype ID for abstract struct companion.DesktopToCompanionEvent: " + subtypeId);
}
}
来自DesktopToCompanionEvent的静态方法的内部调用:
public static createFromStreamAfterIdentification(stream: InputStream): DesktopToCompanionEvent
{
return createDesktopToCompanionEventFromStream(stream);
}
所有index.ts:
export { CompanionToDesktopEvent } from './CompanionToDesktopEvent';
export { DigitCompanionToDesktopEvent } from './DigitCompanionToDesktopEvent';
export { DrawingCompanionToDesktopEvent } from './DrawingCompanionToDesktopEvent';
export { DesktopToCompanionEvent } from './DesktopToCompanionEvent';
export { CodePointDesktopToCompanionEvent } from './CodePointDesktopToCompanionEvent';
export { BaseData } from './BaseData';
export { ExtraData } from './ExtraData';
export { Mode } from './Mode';
export * from './superclassDeserialization'