Skip to content

Commit 496967e

Browse files
clydinleonsenft
authored andcommitted
feat(language-service): add JSON schema for angularCompilerOptions
This commit introduces a JSON schema for angularCompilerOptions in the Angular Language Service extension. It provides validation and autocompletion for Angular-specific options in tsconfig.json files.
1 parent 424ecf8 commit 496967e

File tree

4 files changed

+249
-0
lines changed

4 files changed

+249
-0
lines changed

goldens/vscode-extension/vsix_package_contents.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ node_modules/@angular/language-service/package.json
1212
node_modules/@angular/language-service/plugin-factory.d.ts
1313
node_modules/typescript
1414
package.json
15+
schemas/tsconfig-ng.schema.json
1516
server/README.md
1617
server/bin/ngserver
1718
server/index.js

vscode-ng-language-service/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ npm_package(
4949
"README.md",
5050
"angular.png",
5151
"package_expanded.json",
52+
"schemas/tsconfig-ng.schema.json",
5253
"//vscode-ng-language-service/client:index.js",
5354
"//vscode-ng-language-service/server:npm_package",
5455
"//vscode-ng-language-service/syntaxes:json",

vscode-ng-language-service/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,12 @@
242242
"path": "./syntaxes/expression.json",
243243
"scopeName": "expression.ng"
244244
}
245+
],
246+
"jsonValidation": [
247+
{
248+
"fileMatch": "tsconfig*.json",
249+
"url": "./schemas/tsconfig-ng.schema.json"
250+
}
245251
]
246252
},
247253
"activationEvents": [
Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema",
3+
"title": "Angular options for TypeScript configuration files",
4+
"type": "object",
5+
"definitions": {
6+
"diagnosticCategory": {
7+
"type": "string",
8+
"enum": ["warning", "error", "suppress"]
9+
}
10+
},
11+
"properties": {
12+
"angularCompilerOptions": {
13+
"type": "object",
14+
"properties": {
15+
"allowEmptyCodegenFiles": {
16+
"type": "boolean",
17+
"description": "Generate all possible generated files. This option is not used anymore.",
18+
"deprecated": true
19+
},
20+
"annotateForClosureCompiler": {
21+
"type": "boolean",
22+
"description": "Insert JSDoc type annotations needed by Closure Compiler."
23+
},
24+
"compilationMode": {
25+
"type": "string",
26+
"enum": ["full", "partial", "experimental-local"],
27+
"default": "full",
28+
"description": "Specifies the compilation mode to use."
29+
},
30+
"compileNonExportedClasses": {
31+
"type": "boolean",
32+
"default": true,
33+
"description": "Whether the compiler should avoid generating code for classes that haven't been exported."
34+
},
35+
"disableTypeScriptVersionCheck": {
36+
"type": "boolean",
37+
"description": "Disable TypeScript Version Check."
38+
},
39+
"enableI18nLegacyMessageIdFormat": {
40+
"type": "boolean",
41+
"default": true,
42+
"description": "Render $localize messages with legacy format ids."
43+
},
44+
"extendedDiagnostics": {
45+
"type": "object",
46+
"description": "Options which control how diagnostics are emitted from the compiler.",
47+
"properties": {
48+
"defaultCategory": {
49+
"$ref": "#/definitions/diagnosticCategory",
50+
"description": "The category to use for configurable diagnostics which are not overridden by 'checks'."
51+
},
52+
"checks": {
53+
"type": "object",
54+
"description": "A map of each extended template diagnostic's name to its category.",
55+
"properties": {
56+
"controlFlowPreventingContentProjection": {
57+
"$ref": "#/definitions/diagnosticCategory"
58+
},
59+
"deferTriggerMisconfiguration": {
60+
"$ref": "#/definitions/diagnosticCategory"
61+
},
62+
"interpolatedSignalNotInvoked": {
63+
"$ref": "#/definitions/diagnosticCategory"
64+
},
65+
"invalidBananaInBox": {
66+
"$ref": "#/definitions/diagnosticCategory"
67+
},
68+
"missingControlFlowDirective": {
69+
"$ref": "#/definitions/diagnosticCategory"
70+
},
71+
"missingNgForOfLet": {
72+
"$ref": "#/definitions/diagnosticCategory"
73+
},
74+
"missingStructuralDirective": {
75+
"$ref": "#/definitions/diagnosticCategory"
76+
},
77+
"nullishCoalescingNotNullable": {
78+
"$ref": "#/definitions/diagnosticCategory"
79+
},
80+
"optionalChainNotNullable": {
81+
"$ref": "#/definitions/diagnosticCategory"
82+
},
83+
"skipHydrationNotStatic": {
84+
"$ref": "#/definitions/diagnosticCategory"
85+
},
86+
"suffixNotSupported": {
87+
"$ref": "#/definitions/diagnosticCategory"
88+
},
89+
"textAttributeNotBinding": {
90+
"$ref": "#/definitions/diagnosticCategory"
91+
},
92+
"uninvokedFunctionInEventBinding": {
93+
"$ref": "#/definitions/diagnosticCategory"
94+
},
95+
"uninvokedFunctionInTextInterpolation": {
96+
"$ref": "#/definitions/diagnosticCategory"
97+
},
98+
"uninvokedTrackFunction": {
99+
"$ref": "#/definitions/diagnosticCategory"
100+
},
101+
"unparenthesizedNullishCoalescing": {
102+
"$ref": "#/definitions/diagnosticCategory"
103+
},
104+
"unusedLetDeclaration": {
105+
"$ref": "#/definitions/diagnosticCategory"
106+
},
107+
"unusedStandaloneImports": {
108+
"$ref": "#/definitions/diagnosticCategory"
109+
}
110+
}
111+
}
112+
}
113+
},
114+
"flatModuleId": {
115+
"type": "string",
116+
"description": "Preferred module id to use for importing flat module. Only meaningful when 'flatModuleOutFile' is also supplied."
117+
},
118+
"flatModuleOutFile": {
119+
"type": "string",
120+
"description": "When used, generates a flat module index of the given name and the corresponding flat module metadata."
121+
},
122+
"forbidOrphanComponents": {
123+
"type": "boolean",
124+
"description": "Enables the runtime check to guard against rendering a component without first loading its NgModule."
125+
},
126+
"fullTemplateTypeCheck": {
127+
"type": "boolean",
128+
"description": "Whether to type check the entire template. Superseded by 'strictTemplates'.",
129+
"deprecated": true
130+
},
131+
"generateDeepReexports": {
132+
"type": "boolean",
133+
"description": "Enables the generation of alias re-exports of directives/pipes that are visible from an NgModule from that NgModule's file."
134+
},
135+
"generateExtraImportsInLocalMode": {
136+
"type": "boolean",
137+
"description": "Generates extra imports in local compilation mode which imply the extra imports generated in full mode compilation."
138+
},
139+
"i18nInLocale": {
140+
"type": "string",
141+
"description": "Locale of the imported translations."
142+
},
143+
"i18nNormalizeLineEndingsInICUs": {
144+
"type": "boolean",
145+
"description": "Whether or not to normalize the line-endings (from \r\n to \n) when processing ICU expressions."
146+
},
147+
"i18nOutFile": {
148+
"type": "string",
149+
"description": "Path to the extracted message file to emit when the xi18n operation is requested."
150+
},
151+
"i18nOutFormat": {
152+
"type": "string",
153+
"description": "Export format (xlf, xlf2 or xmb) when the xi18n operation is requested."
154+
},
155+
"i18nOutLocale": {
156+
"type": "string",
157+
"description": "Locale of the application (used when xi18n is requested)."
158+
},
159+
"i18nPreserveWhitespaceForLegacyExtraction": {
160+
"type": "boolean",
161+
"default": true,
162+
"description": "Whether or not to preserve whitespace when extracting messages with the legacy (View Engine) pipeline."
163+
},
164+
"i18nUseExternalIds": {
165+
"type": "boolean",
166+
"description": "Whether translation variable name should contain external message id."
167+
},
168+
"onlyExplicitDeferDependencyImports": {
169+
"type": "boolean",
170+
"description": "Specifies whether Angular compiler should rely on explicit imports via @Component.deferredImports field for @defer blocks."
171+
},
172+
"onlyPublishPublicTypingsForNgModules": {
173+
"type": "boolean",
174+
"description": "Whether the generated type definition for an NgModule will be filtered to only list those types which are publicly exported by the NgModule."
175+
},
176+
"preserveWhitespaces": {
177+
"type": "boolean",
178+
"description": "Whether to remove blank text nodes from compiled templates.",
179+
"default": false
180+
},
181+
"strictAttributeTypes": {
182+
"type": "boolean",
183+
"description": "Whether to check text attributes that happen to be consumed by a directive or component."
184+
},
185+
"strictContextGenerics": {
186+
"type": "boolean",
187+
"description": "Whether to include the generic type of components when type-checking the template."
188+
},
189+
"strictDomEventTypes": {
190+
"type": "boolean",
191+
"description": "Whether to infer the type of the $event variable in event bindings to DOM events."
192+
},
193+
"strictDomLocalRefTypes": {
194+
"type": "boolean",
195+
"description": "Whether to infer the type of local references."
196+
},
197+
"strictInjectionParameters": {
198+
"type": "boolean",
199+
"description": "Whether to report an error when a parameter is supplied whose injection type cannot be determined."
200+
},
201+
"strictInputAccessModifiers": {
202+
"type": "boolean",
203+
"description": "Whether to check if the input binding attempts to assign to a restricted field (readonly, private, or protected) on the directive/component."
204+
},
205+
"strictInputTypes": {
206+
"type": "boolean",
207+
"description": "Whether to check the type of a binding to a directive/component input against the type of the field on the directive/component."
208+
},
209+
"strictLiteralTypes": {
210+
"type": "boolean",
211+
"description": "Whether object or array literals defined in templates use their inferred type, or are interpreted as 'any'."
212+
},
213+
"strictNullInputTypes": {
214+
"type": "boolean",
215+
"description": "Whether to use strict null types for input bindings for directives."
216+
},
217+
"strictOutputEventTypes": {
218+
"type": "boolean",
219+
"description": "Whether to infer the type of the $event variable in event bindings for directive outputs or animation events."
220+
},
221+
"strictSafeNavigationTypes": {
222+
"type": "boolean",
223+
"description": "Whether to use a strict type for null-safe navigation operations."
224+
},
225+
"strictStandalone": {
226+
"type": "boolean",
227+
"description": "If enabled, non-standalone declarations are prohibited and result in build errors."
228+
},
229+
"strictTemplates": {
230+
"type": "boolean",
231+
"description": "If 'true', implies all template strictness flags."
232+
},
233+
"typeCheckHostBindings": {
234+
"type": "boolean",
235+
"description": "Whether type checking of host bindings is enabled."
236+
}
237+
},
238+
"additionalProperties": false
239+
}
240+
}
241+
}

0 commit comments

Comments
 (0)