tangled
alpha
login
or
join now
danabra.mov
/
typelex
56
fork
atom
An experimental TypeSpec syntax for Lexicon
56
fork
atom
overview
issues
1
pulls
2
pipelines
enforce empty @externals
danabra.mov
5 months ago
2b22c7de
a6e8436f
0/1
deploy.yaml
failed
13s
+14
-9
4 changed files
expand all
collapse all
unified
split
packages
emitter
lib
decorators.tsp
src
decorators.ts
emitter.ts
test
spec
external
input
test
external.tsp
-2
packages/emitter/lib/decorators.tsp
···
1
1
import "../dist/tsp-index.js";
2
2
3
3
-
using TypeSpec.Reflection;
4
4
-
5
3
/**
6
4
* Specifies the maximum number of graphemes (user-perceived characters) allowed.
7
5
* Used alongside maxLength for proper Unicode text handling.
+1
packages/emitter/src/decorators.ts
···
310
310
});
311
311
return;
312
312
}
313
313
+
313
314
context.program.stateSet(externalKey).add(target);
314
315
}
315
316
+11
packages/emitter/src/emitter.ts
···
124
124
125
125
// Skip external namespaces - they don't emit JSON files
126
126
if (isExternal(this.program, ns)) {
127
127
+
// Validate that all models in external namespaces are empty (stub-only)
128
128
+
for (const [_, model] of ns.models) {
129
129
+
if (model.properties && model.properties.size > 0) {
130
130
+
this.program.reportDiagnostic({
131
131
+
code: "external-model-not-empty",
132
132
+
severity: "error",
133
133
+
message: `Models in @external namespaces must be empty stubs. Model '${model.name}' in namespace '${fullName}' has properties.`,
134
134
+
target: model,
135
135
+
});
136
136
+
}
137
137
+
}
127
138
return;
128
139
}
129
140
+2
-7
packages/emitter/test/spec/external/input/test/external.tsp
···
2
2
3
3
@external
4
4
namespace test.external {
5
5
-
model Main {
6
6
-
shouldNotEmit: string;
7
7
-
}
5
5
+
model Main { }
8
6
9
9
-
model AlsoNotEmitted {
10
10
-
@required
11
11
-
value: boolean;
12
12
-
}
7
7
+
model AlsoNotEmitted { }
13
8
}