motoko 3.14.4 → 3.14.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.ts CHANGED
@@ -113,19 +113,36 @@ export default function wrapMotoko(compiler: Compiler) {
113
113
  paths: string | string[],
114
114
  scopeCache: Map<string, Scope>,
115
115
  enableRecovery?: boolean,
116
- ): [ParseMotokoTypedWithScopeCacheResult | ParseMotokoTypedWithScopeCacheResult[], Map<string, Scope>] {
116
+ ): [
117
+ (
118
+ | ParseMotokoTypedWithScopeCacheResult
119
+ | ParseMotokoTypedWithScopeCacheResult[]
120
+ ),
121
+ Map<string, Scope>,
122
+ ] {
117
123
  if (enableRecovery === undefined) {
118
124
  enableRecovery = false;
119
125
  }
120
126
  if (typeof paths === 'string') {
121
- const [progs, outCache] = mo.parseMotokoTypedWithScopeCache([paths], scopeCache, enableRecovery);
127
+ const [progs, outCache] = mo.parseMotokoTypedWithScopeCache(
128
+ [paths],
129
+ scopeCache,
130
+ enableRecovery,
131
+ );
122
132
  return [progs[0], outCache];
123
133
  }
124
- const [progs, outCache] =
125
- invoke('parseMotokoTypedWithScopeCache', true, [enableRecovery, paths, scopeCache]);
134
+ const [progs, outCache] = invoke(
135
+ 'parseMotokoTypedWithScopeCache',
136
+ true,
137
+ [enableRecovery, paths, scopeCache],
138
+ );
126
139
  return [
127
140
  progs.map(
128
- ({ ast, typ, immediateImports }: {
141
+ ({
142
+ ast,
143
+ typ,
144
+ immediateImports,
145
+ }: {
129
146
  ast: CompilerNode;
130
147
  typ: CompilerNode;
131
148
  immediateImports: string[];
@@ -210,6 +227,12 @@ export default function wrapMotoko(compiler: Compiler) {
210
227
  setTypecheckerCombineSrcs(combineSrcs: boolean) {
211
228
  invoke('setTypecheckerCombineSrcs', false, [combineSrcs]);
212
229
  },
230
+ setExtraFlags(argv: string[]) {
231
+ if (!Array.isArray(argv)) {
232
+ throw new Error('extra flags must be an array of strings');
233
+ }
234
+ invoke('setExtraFlags', false, [argv]);
235
+ },
213
236
  check(path: string): Diagnostic[] {
214
237
  const result = invoke('check', false, [path]);
215
238
  return result.diagnostics;
@@ -245,9 +268,12 @@ export default function wrapMotoko(compiler: Compiler) {
245
268
  path: string,
246
269
  content: string,
247
270
  enableRecovery = false,
248
- ): { ast: Node, immediateImports: string[] } {
249
- const { ast, immediateImports } =
250
- invoke('parseMotokoWithDeps', true, [enableRecovery, path, content]);
271
+ ): { ast: Node; immediateImports: string[] } {
272
+ const { ast, immediateImports } = invoke(
273
+ 'parseMotokoWithDeps',
274
+ true,
275
+ [enableRecovery, path, content],
276
+ );
251
277
  return { ast: simplifyAST(ast), immediateImports };
252
278
  },
253
279
  parseMotokoTyped,