( content: string, sourceFilename: string, )
| 64 | } |
| 65 | |
| 66 | export function permsTypescriptFileToCode( |
| 67 | content: string, |
| 68 | sourceFilename: string, |
| 69 | ) { |
| 70 | const ast = parse(content, { |
| 71 | sourceFilename, |
| 72 | sourceType: 'module', |
| 73 | errorRecovery: false, |
| 74 | plugins: ['typescript'], |
| 75 | }); |
| 76 | if (ast.errors?.length) { |
| 77 | throw new Error(`Could not parse perms file. ${ast.errors[0].reasonCode}.`); |
| 78 | } |
| 79 | |
| 80 | return astToPermsCode(ast); |
| 81 | } |
no test coverage detected