@typespec/compiler 0.47.0-dev.14 → 0.47.0-dev.19

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.
Files changed (74) hide show
  1. package/dist/manifest.js +2 -2
  2. package/dist/src/config/config-to-options.d.ts +31 -0
  3. package/dist/src/config/config-to-options.d.ts.map +1 -0
  4. package/dist/src/config/config-to-options.js +54 -0
  5. package/dist/src/config/config-to-options.js.map +1 -0
  6. package/dist/src/config/index.d.ts +1 -0
  7. package/dist/src/config/index.d.ts.map +1 -1
  8. package/dist/src/config/index.js +1 -0
  9. package/dist/src/config/index.js.map +1 -1
  10. package/dist/src/core/checker.d.ts.map +1 -1
  11. package/dist/src/core/checker.js +146 -67
  12. package/dist/src/core/checker.js.map +1 -1
  13. package/dist/src/core/cli/actions/compile/args.d.ts.map +1 -1
  14. package/dist/src/core/cli/actions/compile/args.js +27 -65
  15. package/dist/src/core/cli/actions/compile/args.js.map +1 -1
  16. package/dist/src/core/formatter-fs.js +4 -4
  17. package/dist/src/core/formatter-fs.js.map +1 -1
  18. package/dist/src/core/formatter.d.ts +3 -3
  19. package/dist/src/core/formatter.d.ts.map +1 -1
  20. package/dist/src/core/formatter.js +4 -4
  21. package/dist/src/core/formatter.js.map +1 -1
  22. package/dist/src/core/module-resolver.d.ts.map +1 -1
  23. package/dist/src/core/module-resolver.js.map +1 -1
  24. package/dist/src/core/parser.d.ts.map +1 -1
  25. package/dist/src/core/parser.js +35 -8
  26. package/dist/src/core/parser.js.map +1 -1
  27. package/dist/src/core/program.d.ts.map +1 -1
  28. package/dist/src/core/program.js.map +1 -1
  29. package/dist/src/core/types.d.ts +1 -1
  30. package/dist/src/core/types.d.ts.map +1 -1
  31. package/dist/src/emitter-framework/builders/object-builder.d.ts.map +1 -1
  32. package/dist/src/emitter-framework/builders/object-builder.js +1 -0
  33. package/dist/src/emitter-framework/builders/object-builder.js.map +1 -1
  34. package/dist/src/emitter-framework/types.d.ts.map +1 -1
  35. package/dist/src/emitter-framework/types.js.map +1 -1
  36. package/dist/src/formatter/index.d.ts +1 -1
  37. package/dist/src/formatter/index.d.ts.map +1 -1
  38. package/dist/src/formatter/parser.d.ts +2 -6
  39. package/dist/src/formatter/parser.d.ts.map +1 -1
  40. package/dist/src/formatter/parser.js +1 -1
  41. package/dist/src/formatter/parser.js.map +1 -1
  42. package/dist/src/formatter/print/comment-handler.d.ts +1 -1
  43. package/dist/src/formatter/print/comment-handler.d.ts.map +1 -1
  44. package/dist/src/formatter/print/comment-handler.js +1 -2
  45. package/dist/src/formatter/print/comment-handler.js.map +1 -1
  46. package/dist/src/formatter/print/needs-parens.d.ts +1 -1
  47. package/dist/src/formatter/print/needs-parens.d.ts.map +1 -1
  48. package/dist/src/formatter/print/needs-parens.js +1 -0
  49. package/dist/src/formatter/print/needs-parens.js.map +1 -1
  50. package/dist/src/formatter/print/printer.d.ts +41 -40
  51. package/dist/src/formatter/print/printer.d.ts.map +1 -1
  52. package/dist/src/formatter/print/printer.js +6 -4
  53. package/dist/src/formatter/print/printer.js.map +1 -1
  54. package/dist/src/formatter/print/types.d.ts +3 -3
  55. package/dist/src/formatter/print/types.d.ts.map +1 -1
  56. package/dist/src/formatter/print/util.d.ts +3 -0
  57. package/dist/src/formatter/print/util.d.ts.map +1 -0
  58. package/dist/src/formatter/print/util.js +3 -0
  59. package/dist/src/formatter/print/util.js.map +1 -0
  60. package/dist/src/index.d.ts +1 -0
  61. package/dist/src/index.d.ts.map +1 -1
  62. package/dist/src/index.js +1 -0
  63. package/dist/src/index.js.map +1 -1
  64. package/dist/src/init/init.js +1 -1
  65. package/dist/src/init/init.js.map +1 -1
  66. package/dist/src/server/serverlib.d.ts.map +1 -1
  67. package/dist/src/server/serverlib.js +4 -2
  68. package/dist/src/server/serverlib.js.map +1 -1
  69. package/dist/src/server/symbol-structure.d.ts.map +1 -1
  70. package/dist/src/server/symbol-structure.js +3 -1
  71. package/dist/src/server/symbol-structure.js.map +1 -1
  72. package/dist/src/testing/types.d.ts.map +1 -1
  73. package/dist/src/testing/types.js.map +1 -1
  74. package/package.json +2 -3
package/dist/manifest.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export default {
2
- "version": "0.47.0-dev.14",
3
- "commit": "414c466e34e17796f5586704b59836e6e0f3ae56"
2
+ "version": "0.47.0-dev.19",
3
+ "commit": "a12a3fa06d4a243b2dee2f569f4a4ce2f975a6d5"
4
4
  };
@@ -0,0 +1,31 @@
1
+ import { CompilerOptions } from "../core/options.js";
2
+ import { CompilerHost, Diagnostic } from "../core/types.js";
3
+ import { TypeSpecConfig } from "./types.js";
4
+ export interface ResolveCompilerOptionsOptions {
5
+ /** Absolute entrypoint path */
6
+ entrypoint: string;
7
+ /** Explicit config path. */
8
+ configPath?: string;
9
+ /** Current working directory. This will be used to interpolate `{cwd}` in the config.
10
+ * @default to `process.cwd()`
11
+ */
12
+ cwd?: string;
13
+ /**
14
+ * Environment variables.
15
+ * @default process.env
16
+ */
17
+ env?: Record<string, string | undefined>;
18
+ /**
19
+ * Any arguments to interpolate the config.
20
+ */
21
+ args?: Record<string, string>;
22
+ /** Compiler options to override the config */
23
+ overrides?: Partial<TypeSpecConfig>;
24
+ }
25
+ /**
26
+ * Resolve the compiler options for the given entrypoint by resolving the tspconfig.yaml.
27
+ * @param host Compiler host
28
+ * @param compilerOptions
29
+ */
30
+ export declare function resolveCompilerOptions(host: CompilerHost, options: ResolveCompilerOptionsOptions): Promise<[CompilerOptions, readonly Diagnostic[]]>;
31
+ //# sourceMappingURL=config-to-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-to-options.d.ts","sourceRoot":"","sources":["../../../src/config/config-to-options.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAI5D,OAAO,EAAkB,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5D,MAAM,WAAW,6BAA6B;IAC5C,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAC;IAEnB,4BAA4B;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAEzC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE9B,8CAA8C;IAC9C,SAAS,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;CACrC;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,CAAC,eAAe,EAAE,SAAS,UAAU,EAAE,CAAC,CAAC,CAoCnD"}
@@ -0,0 +1,54 @@
1
+ import { createDiagnosticCollector, getDirectoryPath, normalizePath } from "../core/index.js";
2
+ import { deepClone, omitUndefined } from "../core/util.js";
3
+ import { expandConfigVariables } from "./config-interpolation.js";
4
+ import { loadTypeSpecConfigForPath, validateConfigPathsAbsolute } from "./config-loader.js";
5
+ /**
6
+ * Resolve the compiler options for the given entrypoint by resolving the tspconfig.yaml.
7
+ * @param host Compiler host
8
+ * @param compilerOptions
9
+ */
10
+ export async function resolveCompilerOptions(host, options) {
11
+ var _a, _b, _c, _d, _e;
12
+ const cwd = normalizePath((_a = options.cwd) !== null && _a !== void 0 ? _a : process.cwd());
13
+ const diagnostics = createDiagnosticCollector();
14
+ const entrypointStat = await host.stat(options.entrypoint);
15
+ const configPath = ((_b = options.configPath) !== null && _b !== void 0 ? _b : entrypointStat.isDirectory())
16
+ ? options.entrypoint
17
+ : getDirectoryPath(options.entrypoint);
18
+ const config = await loadTypeSpecConfigForPath(host, configPath);
19
+ const configWithOverrides = {
20
+ ...config,
21
+ ...options.overrides,
22
+ options: mergeOptions(config.options, (_c = options.overrides) === null || _c === void 0 ? void 0 : _c.options),
23
+ };
24
+ const expandedConfig = diagnostics.pipe(expandConfigVariables(configWithOverrides, {
25
+ cwd,
26
+ outputDir: (_d = options.overrides) === null || _d === void 0 ? void 0 : _d.outputDir,
27
+ env: (_e = options.env) !== null && _e !== void 0 ? _e : process.env,
28
+ args: options.args,
29
+ }));
30
+ validateConfigPathsAbsolute(expandedConfig).forEach((x) => diagnostics.add(x));
31
+ const resolvedOptions = omitUndefined({
32
+ outputDir: expandedConfig.outputDir,
33
+ config: config.filename,
34
+ additionalImports: expandedConfig["imports"],
35
+ warningAsError: expandedConfig.warnAsError,
36
+ trace: expandedConfig.trace,
37
+ emit: expandedConfig.emit,
38
+ options: expandedConfig.options,
39
+ linterRuleSet: expandedConfig.linter,
40
+ });
41
+ return diagnostics.wrap(resolvedOptions);
42
+ }
43
+ function mergeOptions(base, overrides) {
44
+ var _a;
45
+ const configuredEmitters = deepClone(base !== null && base !== void 0 ? base : {});
46
+ for (const [emitterName, cliOptionOverride] of Object.entries(overrides !== null && overrides !== void 0 ? overrides : {})) {
47
+ configuredEmitters[emitterName] = {
48
+ ...((_a = configuredEmitters[emitterName]) !== null && _a !== void 0 ? _a : {}),
49
+ ...cliOptionOverride,
50
+ };
51
+ }
52
+ return configuredEmitters;
53
+ }
54
+ //# sourceMappingURL=config-to-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-to-options.js","sourceRoot":"","sources":["../../../src/config/config-to-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAG9F,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AA8B5F;;;;GAIG;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AE,MAAM,CAAC,QAAQ;QACvB,iBAAiB,EAAE,cAAc,CAAC,SAAS,CAAC;QAC5C,cAAc,EAAE,cAAc,CAAC,WAAW;QAC1C,KAAK,EAAE,cAAc,CAAC,KAAK;QAC3B,IAAI,EAAE,cAAc,CAAC,IAAI;QACzB,OAAO,EAAE,cAAc,CAAC,OAAO;QAC/B,aAAa,EAAE,cAAc,CAAC,MAAM;KACrC,CAAC,CAAC;IACH,OAAO,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,YAAY,CACnB,IAAyD,EACzD,SAA8D;;IAE9D,MAAM,kBAAkB,GAA4C,SAAS,CAAC,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,CAAC,CAAC;IAE1F,KAAK,MAAM,CAAC,WAAW,EAAE,iBAAiB,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAC,EAAE;QAC9E,kBAAkB,CAAC,WAAW,CAAC,GAAG;YAChC,GAAG,CAAC,MAAA,kBAAkB,CAAC,WAAW,CAAC,mCAAI,EAAE,CAAC;YAC1C,GAAG,iBAAiB;SACrB,CAAC;KACH;IAED,OAAO,kBAAkB,CAAC;AAC5B,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from "./config-loader.js";
2
+ export { ResolveCompilerOptionsOptions, resolveCompilerOptions } from "./config-to-options.js";
2
3
  export * from "./types.js";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,6BAA6B,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAC/F,cAAc,YAAY,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from "./config-loader.js";
2
+ export { resolveCompilerOptions } from "./config-to-options.js";
2
3
  export * from "./types.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAiC,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAC/F,cAAc,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"checker.d.ts","sourceRoot":"","sources":["../../../src/core/checker.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAqC,MAAM,oBAAoB,CAAC;AAGxF,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAUzD,OAAO,EAIL,cAAc,EACd,kBAAkB,EAQlB,UAAU,EACV,gBAAgB,EAMhB,SAAS,EAKT,YAAY,EAEZ,cAAc,EAId,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,WAAW,EAOX,KAAK,EAGL,aAAa,EAKb,SAAS,EACT,sBAAsB,EACtB,SAAS,EACT,IAAI,EAEJ,cAAc,EACd,kBAAkB,EAiBlB,cAAc,EAGd,uBAAuB,EAIvB,MAAM,EAEN,WAAW,EACX,QAAQ,EACR,aAAa,EACb,iBAAiB,EACjB,GAAG,EAYH,IAAI,EAIJ,iBAAiB,EACjB,kBAAkB,EAMlB,WAAW,EAEX,SAAS,EACT,QAAQ,EACT,MAAM,YAAY,CAAC;AAGpB,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,aAAa,CAAC,CAAC;AAE7E,MAAM,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AED,UAAU,aAAa;IACrB,WAAW,EAAE,uBAAuB,EAAE,CAAC;IACvC,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,uBAAuB,EAAE,CAAC;CAC5D;AAED,6CAA6C;AAC7C,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,CAAC;AAExD,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,GAAG,CAAC;IAET;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAaD,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAu8JvD;AAqFD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,OAAO,GAC5C,KAAK,CAyEP;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,GAAG,gBAAgB,EACnC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,OAAO,GAC3C,KAAK,CAmCP;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa,GAAG,aAAa,GAAG,SAAS,CAcxF;AAED;;;;;;;GAOG;AACH,wBAAiB,uBAAuB,CAAC,KAAK,EAAE,KAAK,2CAapD;AAYD,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,CAEpF"}
@@ -1082,7 +1082,8 @@ export function createChecker(program) {
1082
1082
  function checkOperation(node, mapper, parentInterface) {
1083
1083
  var _a;
1084
1084
  const inInterface = ((_a = node.parent) === null || _a === void 0 ? void 0 : _a.kind) === SyntaxKind.InterfaceStatement;
1085
- const links = inInterface ? getSymbolLinksForMember(node) : getSymbolLinks(node.symbol);
1085
+ const symbol = inInterface ? getSymbolForMember(node) : node.symbol;
1086
+ const links = symbol && getSymbolLinks(symbol);
1086
1087
  if (links) {
1087
1088
  if (links.declaredType && mapper === undefined) {
1088
1089
  // we're not instantiating this operation and we've already checked it
@@ -1109,8 +1110,19 @@ export function createChecker(program) {
1109
1110
  return errorType;
1110
1111
  }
1111
1112
  sourceOperation = baseOperation;
1113
+ const parameterModelSym = getOrCreateAugmentedSymbolTable(symbol.metatypeMembers).get("parameters");
1112
1114
  // Reference the same return type and create the parameters type
1113
- parameters = cloneType(baseOperation.parameters);
1115
+ const clone = initializeClone(baseOperation.parameters, {
1116
+ properties: createRekeyableMap(),
1117
+ });
1118
+ clone.properties = createRekeyableMap(Array.from(baseOperation.parameters.properties.entries()).map(([key, prop]) => [
1119
+ key,
1120
+ cloneTypeForSymbol(getMemberSymbol(parameterModelSym, prop.name), prop, {
1121
+ model: clone,
1122
+ sourceProperty: prop,
1123
+ }),
1124
+ ]));
1125
+ parameters = finishType(clone);
1114
1126
  returnType = baseOperation.returnType;
1115
1127
  // Copy decorators from the base operation, inserting the base decorators first
1116
1128
  decorators = [...baseOperation.decorators];
@@ -1774,13 +1786,6 @@ export function createChecker(program) {
1774
1786
  }
1775
1787
  // Evaluate the properties after
1776
1788
  checkModelProperties(node, type.properties, type, mapper);
1777
- for (const prop of walkPropertiesInherited(type)) {
1778
- const table = getOrCreateAugmentedSymbolTable(node.symbol.members);
1779
- const sym = table.get(prop.name);
1780
- if (sym) {
1781
- mutate(sym).type = prop;
1782
- }
1783
- }
1784
1789
  linkMapper(type, mapper);
1785
1790
  if (shouldCreateTypeForTemplate(node, mapper)) {
1786
1791
  finishType(type);
@@ -1844,7 +1849,7 @@ export function createChecker(program) {
1844
1849
  }
1845
1850
  else {
1846
1851
  // spread property
1847
- const newProperties = checkSpreadProperty(prop.target, parentModel, mapper);
1852
+ const newProperties = checkSpreadProperty(node.symbol, prop.target, parentModel, mapper);
1848
1853
  for (const newProp of newProperties) {
1849
1854
  linkIndirectMember(node, newProp, mapper);
1850
1855
  checkPropertyCompatibleWithIndexer(parentModel, newProp, prop);
@@ -1944,6 +1949,9 @@ export function createChecker(program) {
1944
1949
  break;
1945
1950
  case SyntaxKind.UnionStatement:
1946
1951
  for (const variant of node.options.values()) {
1952
+ if (!variant.id) {
1953
+ continue;
1954
+ }
1947
1955
  const name = variant.id.sv;
1948
1956
  bindMember(name, variant, 1024 /* SymbolFlags.UnionVariant */);
1949
1957
  }
@@ -1989,40 +1997,68 @@ export function createChecker(program) {
1989
1997
  }
1990
1998
  }
1991
1999
  }
1992
- function bindMetaTypes(node) {
2000
+ function copyMembersToContainer(targetContainerSym, table) {
1993
2001
  var _a;
1994
- switch (node.kind) {
1995
- case SyntaxKind.ModelProperty: {
1996
- const sym = getSymbolForMember(node);
1997
- if (sym) {
1998
- const table = getOrCreateAugmentedSymbolTable(sym.metatypeMembers);
1999
- table.set("type", node.value.kind === SyntaxKind.TypeReference
2000
- ? createSymbol(node.value, "", 2048 /* SymbolFlags.Alias */)
2001
- : node.value.symbol);
2002
- }
2003
- break;
2002
+ const members = (_a = augmentedSymbolTables.get(table)) !== null && _a !== void 0 ? _a : table;
2003
+ compilerAssert(targetContainerSym.members, "containerSym.members is undefined");
2004
+ const containerMembers = getOrCreateAugmentedSymbolTable(targetContainerSym.members);
2005
+ for (const member of members.values()) {
2006
+ bindMemberToContainer(targetContainerSym, containerMembers, member.name, member.declarations[0], member.flags);
2007
+ }
2008
+ }
2009
+ function bindMemberToContainer(containerSym, containerMembers, name, node, kind) {
2010
+ const sym = createSymbol(node, name, kind, containerSym);
2011
+ compilerAssert(containerSym.members, "containerSym.members is undefined");
2012
+ containerMembers.set(name, sym);
2013
+ }
2014
+ function bindMetaTypes(node) {
2015
+ const visited = new Set();
2016
+ function visit(node, symbol) {
2017
+ var _a;
2018
+ if (visited.has(node)) {
2019
+ return;
2004
2020
  }
2005
- case SyntaxKind.OperationStatement: {
2006
- const sym = (_a = node.symbol) !== null && _a !== void 0 ? _a : getSymbolForMember(node);
2007
- const table = getOrCreateAugmentedSymbolTable(sym.metatypeMembers);
2008
- if (node.signature.kind === SyntaxKind.OperationSignatureDeclaration) {
2009
- table.set("parameters", node.signature.parameters.symbol);
2010
- table.set("returnType", node.signature.returnType.symbol);
2021
+ visited.add(node);
2022
+ switch (node.kind) {
2023
+ case SyntaxKind.ModelProperty: {
2024
+ const sym = getSymbolForMember(node);
2025
+ if (sym) {
2026
+ const table = getOrCreateAugmentedSymbolTable(sym.metatypeMembers);
2027
+ table.set("type", node.value.kind === SyntaxKind.TypeReference
2028
+ ? createSymbol(node.value, "", 2048 /* SymbolFlags.Alias */)
2029
+ : node.value.symbol);
2030
+ }
2031
+ break;
2011
2032
  }
2012
- else {
2013
- const sig = resolveTypeReferenceSym(node.signature.baseOperation, undefined);
2014
- if (sig) {
2015
- const sigTable = getOrCreateAugmentedSymbolTable(sig.metatypeMembers);
2016
- table.set("parameters", sigTable.get("parameters"));
2017
- table.set("returnType", sigTable.get("returnType"));
2033
+ case SyntaxKind.OperationStatement: {
2034
+ const sym = (_a = symbol !== null && symbol !== void 0 ? symbol : node.symbol) !== null && _a !== void 0 ? _a : getSymbolForMember(node);
2035
+ const table = getOrCreateAugmentedSymbolTable(sym.metatypeMembers);
2036
+ if (node.signature.kind === SyntaxKind.OperationSignatureDeclaration) {
2037
+ table.set("parameters", node.signature.parameters.symbol);
2038
+ table.set("returnType", node.signature.returnType.symbol);
2018
2039
  }
2040
+ else {
2041
+ const sig = resolveTypeReferenceSym(node.signature.baseOperation, undefined);
2042
+ if (sig) {
2043
+ visit(sig.declarations[0], sig);
2044
+ const sigTable = getOrCreateAugmentedSymbolTable(sig.metatypeMembers);
2045
+ const sigParameterSym = sigTable.get("parameters");
2046
+ if (sigParameterSym !== undefined) {
2047
+ const parametersSym = createSymbol(sigParameterSym.declarations[0], "parameters", 2 /* SymbolFlags.Model */ & 674 /* SymbolFlags.MemberContainer */);
2048
+ copyMembersToContainer(parametersSym, sigParameterSym.members);
2049
+ table.set("parameters", parametersSym);
2050
+ table.set("returnType", sigTable.get("returnType"));
2051
+ }
2052
+ }
2053
+ }
2054
+ break;
2019
2055
  }
2020
- break;
2021
2056
  }
2057
+ visitChildren(node, (child) => {
2058
+ bindMetaTypes(child);
2059
+ });
2022
2060
  }
2023
- visitChildren(node, (child) => {
2024
- bindMetaTypes(child);
2025
- });
2061
+ visit(node);
2026
2062
  }
2027
2063
  /**
2028
2064
  * Initializes a late bound symbol for the type. This is generally necessary when attempting to
@@ -2184,7 +2220,7 @@ export function createChecker(program) {
2184
2220
  }
2185
2221
  return isType;
2186
2222
  }
2187
- function checkSpreadProperty(targetNode, parentModel, mapper) {
2223
+ function checkSpreadProperty(parentModelSym, targetNode, parentModel, mapper) {
2188
2224
  const targetType = getTypeForNode(targetNode, mapper);
2189
2225
  if (targetType.kind === "TemplateParameter" || isErrorType(targetType)) {
2190
2226
  return [];
@@ -2196,7 +2232,8 @@ export function createChecker(program) {
2196
2232
  const props = [];
2197
2233
  // copy each property
2198
2234
  for (const prop of walkPropertiesInherited(targetType)) {
2199
- props.push(cloneType(prop, {
2235
+ const memberSym = getMemberSymbol(parentModelSym, prop.name);
2236
+ props.push(cloneTypeForSymbol(memberSym, prop, {
2200
2237
  sourceProperty: prop,
2201
2238
  model: parentModel,
2202
2239
  }));
@@ -2429,6 +2466,18 @@ export function createChecker(program) {
2429
2466
  }
2430
2467
  return valid;
2431
2468
  }
2469
+ function checkAugmentDecorators(sym, targetType, mapper) {
2470
+ var _a;
2471
+ const augmentDecoratorNodes = (_a = augmentDecoratorsForSym.get(sym)) !== null && _a !== void 0 ? _a : [];
2472
+ const decorators = [];
2473
+ for (const decNode of augmentDecoratorNodes) {
2474
+ const decorator = checkDecorator(targetType, decNode, mapper);
2475
+ if (decorator) {
2476
+ decorators.unshift(decorator);
2477
+ }
2478
+ }
2479
+ return decorators;
2480
+ }
2432
2481
  function checkDecorators(targetType, node, mapper) {
2433
2482
  var _a, _b;
2434
2483
  const sym = isMemberNode(node) ? (_a = getSymbolForMember(node)) !== null && _a !== void 0 ? _a : node.symbol : node.symbol;
@@ -2449,7 +2498,7 @@ export function createChecker(program) {
2449
2498
  if (docComment) {
2450
2499
  decorators.unshift({
2451
2500
  decorator: $docFromComment,
2452
- args: [{ value: program.checker.createLiteralType(docComment), jsValue: docComment }],
2501
+ args: [{ value: createLiteralType(docComment), jsValue: docComment }],
2453
2502
  });
2454
2503
  }
2455
2504
  return decorators;
@@ -2582,7 +2631,7 @@ export function createChecker(program) {
2582
2631
  enumType.members.set(memberType.name, memberType);
2583
2632
  }
2584
2633
  else {
2585
- const members = checkEnumSpreadMember(enumType, member.target, mapper, memberNames);
2634
+ const members = checkEnumSpreadMember(node.symbol, enumType, member.target, mapper, memberNames);
2586
2635
  for (const memberType of members) {
2587
2636
  linkIndirectMember(node, memberType, mapper);
2588
2637
  enumType.members.set(memberType.name, memberType);
@@ -2632,7 +2681,9 @@ export function createChecker(program) {
2632
2681
  target: extendsNode,
2633
2682
  }));
2634
2683
  }
2635
- const newMember = cloneType(member, { interface: interfaceType });
2684
+ const newMember = cloneTypeForSymbol(getMemberSymbol(node.symbol, member.name), member, {
2685
+ interface: interfaceType,
2686
+ });
2636
2687
  // Don't link it it is overritten
2637
2688
  if (!ownMembers.has(member.name)) {
2638
2689
  linkIndirectMember(node, newMember, mapper);
@@ -2727,7 +2778,7 @@ export function createChecker(program) {
2727
2778
  // we're not instantiating this union variant and we've already checked it
2728
2779
  return links.declaredType;
2729
2780
  }
2730
- const name = variantNode.id.sv;
2781
+ const name = variantNode.id ? variantNode.id.sv : Symbol("name");
2731
2782
  const type = getTypeForNode(variantNode.value, mapper);
2732
2783
  const variantType = createType({
2733
2784
  kind: "UnionVariant",
@@ -2753,8 +2804,14 @@ export function createChecker(program) {
2753
2804
  node.kind === SyntaxKind.OperationStatement ||
2754
2805
  node.kind === SyntaxKind.UnionVariant);
2755
2806
  }
2807
+ function getMemberSymbol(parentSym, name) {
2808
+ return parentSym ? getOrCreateAugmentedSymbolTable(parentSym.members).get(name) : undefined;
2809
+ }
2756
2810
  function getSymbolForMember(node) {
2757
2811
  var _a;
2812
+ if (!node.id) {
2813
+ return undefined;
2814
+ }
2758
2815
  const name = node.id.sv;
2759
2816
  const parentSym = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.symbol;
2760
2817
  return parentSym ? getOrCreateAugmentedSymbolTable(parentSym.members).get(name) : undefined;
@@ -2785,7 +2842,7 @@ export function createChecker(program) {
2785
2842
  member.decorators = checkDecorators(member, node, mapper);
2786
2843
  return finishType(member);
2787
2844
  }
2788
- function checkEnumSpreadMember(parentEnum, targetNode, mapper, existingMemberNames) {
2845
+ function checkEnumSpreadMember(parentEnumSym, parentEnum, targetNode, mapper, existingMemberNames) {
2789
2846
  const members = [];
2790
2847
  const targetType = getTypeForNode(targetNode, mapper);
2791
2848
  if (!isErrorType(targetType)) {
@@ -2803,7 +2860,8 @@ export function createChecker(program) {
2803
2860
  }
2804
2861
  else {
2805
2862
  existingMemberNames.add(member.name);
2806
- const clonedMember = cloneType(member, {
2863
+ const memberSym = getMemberSymbol(parentEnumSym, member.name);
2864
+ const clonedMember = cloneTypeForSymbol(memberSym, member, {
2807
2865
  enum: parentEnum,
2808
2866
  sourceMember: member,
2809
2867
  });
@@ -2992,23 +3050,7 @@ export function createChecker(program) {
2992
3050
  getSymbolLinks(globalNamespaceNode.symbol).type = type;
2993
3051
  return type;
2994
3052
  }
2995
- /**
2996
- * Clone a type, resulting in an identical type with all the same decorators
2997
- * applied. Decorators are re-run on the clone to achieve this.
2998
- *
2999
- * Care is taken to clone nested data structures that are part of the type.
3000
- * Any type with e.g. a map or an array property must recreate the map or array
3001
- * so that clones don't share the same object.
3002
- *
3003
- * For types which have sub-types that are part of it, e.g. enums with members,
3004
- * unions with variants, or models with properties, the sub-types are cloned
3005
- * as well.
3006
- *
3007
- * If the entire type graph needs to be cloned, then cloneType must be called
3008
- * recursively by the caller.
3009
- */
3010
- function cloneType(type, additionalProps = {}) {
3011
- // TODO: this needs to handle other types
3053
+ function initializeClone(type, additionalProps) {
3012
3054
  let clone;
3013
3055
  switch (type.kind) {
3014
3056
  case "Model":
@@ -3024,7 +3066,7 @@ export function createChecker(program) {
3024
3066
  cloneType(prop, { model: newModel }),
3025
3067
  ]));
3026
3068
  }
3027
- clone = finishType(newModel);
3069
+ clone = newModel;
3028
3070
  break;
3029
3071
  case "Union":
3030
3072
  const newUnion = createType({
@@ -3042,7 +3084,7 @@ export function createChecker(program) {
3042
3084
  cloneType(prop, { union: newUnion }),
3043
3085
  ]));
3044
3086
  }
3045
- clone = finishType(newUnion);
3087
+ clone = newUnion;
3046
3088
  break;
3047
3089
  case "Interface":
3048
3090
  const newInterface = createType({
@@ -3057,7 +3099,7 @@ export function createChecker(program) {
3057
3099
  cloneType(prop, { interface: newInterface }),
3058
3100
  ]));
3059
3101
  }
3060
- clone = finishType(newInterface);
3102
+ clone = newInterface;
3061
3103
  break;
3062
3104
  case "Enum":
3063
3105
  const newEnum = createType({
@@ -3072,16 +3114,35 @@ export function createChecker(program) {
3072
3114
  cloneType(prop, { enum: newEnum }),
3073
3115
  ]));
3074
3116
  }
3075
- clone = finishType(newEnum);
3117
+ clone = newEnum;
3076
3118
  break;
3077
3119
  default:
3078
- clone = createAndFinishType({
3120
+ clone = createType({
3079
3121
  ...type,
3080
3122
  ...("decorators" in type ? { decorators: [...type.decorators] } : {}),
3081
3123
  ...additionalProps,
3082
3124
  });
3083
3125
  break;
3084
3126
  }
3127
+ return clone;
3128
+ }
3129
+ /**
3130
+ * Clone a type, resulting in an identical type with all the same decorators
3131
+ * applied. Decorators are re-run on the clone to achieve this.
3132
+ *
3133
+ * Care is taken to clone nested data structures that are part of the type.
3134
+ * Any type with e.g. a map or an array property must recreate the map or array
3135
+ * so that clones don't share the same object.
3136
+ *
3137
+ * For types which have sub-types that are part of it, e.g. enums with members,
3138
+ * unions with variants, or models with properties, the sub-types are cloned
3139
+ * as well.
3140
+ *
3141
+ * If the entire type graph needs to be cloned, then cloneType must be called
3142
+ * recursively by the caller.
3143
+ */
3144
+ function cloneType(type, additionalProps = {}) {
3145
+ const clone = finishType(initializeClone(type, additionalProps));
3085
3146
  const projection = projectionsByType.get(type);
3086
3147
  if (projection) {
3087
3148
  projectionsByType.set(clone, projection);
@@ -3089,6 +3150,24 @@ export function createChecker(program) {
3089
3150
  compilerAssert(clone.kind === type.kind, "cloneType must not change type kind");
3090
3151
  return clone;
3091
3152
  }
3153
+ /**
3154
+ * Clone a type linking to the given symbol.
3155
+ * @param sym Symbol which to associate the clone
3156
+ * @param type Type to clone
3157
+ * @param additionalProps Additional properties to set/override on the clone
3158
+ * @returns cloned type
3159
+ */
3160
+ function cloneTypeForSymbol(sym, type, additionalProps = {}) {
3161
+ let clone = initializeClone(type, additionalProps);
3162
+ if ("decorators" in clone) {
3163
+ for (const dec of checkAugmentDecorators(sym, clone, undefined)) {
3164
+ clone.decorators.push(dec);
3165
+ }
3166
+ }
3167
+ clone = finishType(clone);
3168
+ compilerAssert(clone.kind === type.kind, "cloneType must not change type kind");
3169
+ return clone;
3170
+ }
3092
3171
  function checkProjectionDeclaration(node) {
3093
3172
  // todo: check for duplicate projection decls on individual types
3094
3173
  // right now you can declare the same projection on a specific type