Created
May 10, 2019 20:11
-
-
Save felher/b202b6ccead15d3d2cc7803ed68e5f59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function linePairContainerParser():P.Parser<M.FormteilContainer>{ | |
return P.regexp(/[0-9]+/).map(num => ( | |
{ | |
"kind": M.ContainerKind.FormteilContainer, | |
uuid: UUID(), | |
children: [] | |
})); | |
} | |
// this fails with: | |
//ERROR in src/app/types/parser.ts(92,3): error TS2322: Type 'Parser<{ "kind": ContainerKind; uuid: string; children: never[]; data: { "kind": FormteilDataKind; number: string; }; }>' is not assignable to type 'Parser<FormteilContainer>'. | |
// Type '{ "kind": ContainerKind; uuid: string; children: never[]; data: { "kind": FormteilDataKind; number: string; }; }' is not assignable to type 'FormteilContainer'. | |
// Types of property '"kind"' are incompatible. | |
// Type 'ContainerKind' is not assignable to type 'ContainerKind.FormteilContainer | |
// | |
// while this works just fine: | |
function linePairContainerParser():P.Parser<M.FormteilContainer>{ | |
const k: M.ContainerKind.FormteilContainer = M.ContainerKind.FormteilContainer; | |
return P.regexp(/[0-9]+/).map(num => ( | |
{ | |
"kind": k, | |
uuid: UUID(), | |
children: [] | |
})); | |
} | |
// ContainerKind looks like this: | |
export enum ContainerKind { | |
FormteilContainer = "FormteilContainer", | |
MiscContainer = "MiscContainer", | |
ParatextContainer = "ParatextContainer", | |
RootContainer = "RootContainer", | |
ZeileContainer = "ZeileContainer", | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment