Skip to content

Commit e5068b0

Browse files
committed
Doc
1 parent 6997142 commit e5068b0

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

Doc/images/TS2531Warning.jpg

27.4 KB
Loading

SettingsExplained.md

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ And WebApiClientGen receives settings through an API call "api/codegen" with a P
66

77
The schema and the semantic meanings of the JSON data are described in "[CodeGenParameters](https://github.com/zijianhuang/webapiclientgen/blob/master/WebApiClientGenCore.Abstract/CodeGenParameters.cs)". And the followig sections give further explaination.
88

9-
![Packages](/Doc/images/Settings.png)
9+
![Packages](Doc/images/Settings.png)
1010

1111
## ApiSelection
1212

@@ -272,12 +272,6 @@ Nevertheless, for TypeScript client codes, the mapping is always `Array<T>`.
272272

273273
IDictionary<T> and its derived types will always be mapped to respective types. Nevertheless, for TypeScript client codes, the mapping is always `{[index:T]:Y}`.
274274

275-
### HelpStrictMode
276-
277-
Give TypeScript strict mode more signal for null value in both data models and client API functions. The returned types and parameters may be null. And some primitive types in data model / interface may be null.
278-
279-
Except for legacy TypeScript apps that you don't plan to conform to the strict mode, it is recommended to turn this option on. For more details, please check [Required, Optional and Nullable in TypeScript](Required-Optional-Nullable).
280-
281275
### MaybeNullAttributeOnMethod
282276

283277
When this setting is on along with HelpStrictMode=true, the return type of API functions associated with MaybeNullAttribute has an alternative type null, so to signal client codes that the return may be null, and the return type of all other functions will be without an alternative type null.
@@ -305,7 +299,7 @@ getHero(id?: number, headersHandler?: () => HttpHeaders): Observable<DemoWebApi_
305299

306300
At the mean time, all other functions without
307301

308-
![TS2532 warning](https://github.com/zijianhuang/webapiclientgen/blob/gh-pages/media/Screenshot%202022-07-15%20115132.jpg)
302+
![TS2531 warning](Doc/images/TS2531Warning.jpg)
309303

310304
So you should then do:
311305
```js
@@ -609,7 +603,7 @@ public async Task AddPetAsync(Pet requestBody, System.Threading.CancellationToke
609603
}
610604
```
611605

612-
## Plugins
606+
## TypeScript Plugins
613607

614608
Plugins are for plugin assemblies that generate TypeScript codes for JavaScript libraries and frameworks.
615609

@@ -728,3 +722,38 @@ TypeScript client codes:
728722
* [Dealing with Large Integral Numbers in JavaScript for Integral Types of ASP.NET Core Web API](https://www.codeproject.com/Articles/5377807/Dealing-with-large-integral-numbers-in-JavaScript)
729723
* [Enjoy Rich Integral Types of .NET and Overcome the 53-bit Limitation of JavaScript](https://www.codeproject.com/Articles/5378038/Enjoy-rich-integral-types-of-NET-and-overcome-the)
730724
725+
### HelpStrictMode
726+
727+
Give TypeScript strict mode more signal for null value in both data models and client API functions. The returned types and parameters may be null. And some primitive types in data model / interface may be null.
728+
729+
Except for legacy TypeScript apps that you don't plan to conform to the strict mode, it is recommended to turn this option on. For more details, please check [Required, Optional and Nullable in TypeScript](Required-Optional-Nullable).
730+
731+
### NgDateOnlyFormControlEnabled
732+
733+
For Angular Reactive Forms dealing with DateOnly fields.
734+
735+
When true, the FormControl generated is like:
736+
737+
738+
```js
739+
export function CreateHeroFormGroup() {
740+
return new FormGroup<HeroFormProperties>({
741+
death: CreateDateOnlyFormControl(),
742+
dob: CreateDateOnlyFormControl(),
743+
emailAddress: new FormControl<string | null | undefined>(undefined, [Validators.email]),
744+
...
745+
...
746+
function CreateDateOnlyFormControl(){
747+
const fc = new FormControl<any | null | undefined>(undefined);
748+
fc.valueChanges.subscribe(v=>{
749+
if (v && v instanceof Date){
750+
fc.setValue(v.toLocaleDateString("sv").substring(0, 10));
751+
}
752+
});
753+
754+
return fc;
755+
}
756+
757+
Hints:
758+
* JavaScript Date object is always internally UTC DateTime, while HTML date picker and Angular Material DatePicker handle well both JS Date object and string. However, for DateOnly info, this FormControl generated enforce string "yyyy-MM-dd".
759+
```

0 commit comments

Comments
 (0)