Skip to content

Commit

Permalink
docs(all): fix letter case (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
sisisin authored Jul 22, 2020
1 parent 45f8983 commit 9173c18
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dist/
node_modules/
jspm_packages/

# Typescript v1 declaration files
# TypeScript v1 declaration files
typings/

# Optional npm cache directory
Expand Down
18 changes: 9 additions & 9 deletions docs-src/src/content/pages/advanced/typescript/en.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Typescript Support
title: TypeScript Support
categories: [advanced]
order: 60
meta:
Expand All @@ -16,7 +16,7 @@ CASL is written in [TypeScript] and this brings several benefits:

So, let's play around with them

> Minimum supported Typescript version is **3.5.3**
> Minimum supported TypeScript version is **3.5.3**
## Permissions inference

Expand Down Expand Up @@ -61,15 +61,15 @@ If you try to type `ability.can(` in [VSCode] (it should work in other IDEs that

[VSCode]: https://code.visualstudio.com/

![CASL Typescript action hints](./casl-action-hints.png)
![CASL TypeScript action hints](./casl-action-hints.png)

The same happens when you try to specify the 2nd argument:

![CASL Typescript subject hints](./casl-subject-hints.png)
![CASL TypeScript subject hints](./casl-subject-hints.png)

The same behavior works for `AbilityBuilder` and `defineAbility` functions as well:

![CASL Typescript AbilityBuilder hints](./casl-abilitybuilder.png)
![CASL TypeScript AbilityBuilder hints](./casl-abilitybuilder.png)

## Infer subject types from interfaces and classes

Expand Down Expand Up @@ -133,19 +133,19 @@ This may be a bit routine to specify all possible subject types, especially if y

> `__caslSubjectType__` is set by `subject` helper, to learn more check [Subject type detection](../../guide/subject-type-detection)
![CASL Typescript infer tagged union subject](./casl-tagged-union-subject.png)
![CASL TypeScript infer tagged union subject](./casl-tagged-union-subject.png)

classes

![CASL Typescript infer class subject](./casl-class-subject.png)
![CASL TypeScript infer class subject](./casl-class-subject.png)

and even discriminated classes (you need to pass `true` to the 2nd generic parameter of `InferSubjects`).

![CASL Typescript infer discriminated class subject](./casl-discriminated-class-subject.png)
![CASL TypeScript infer discriminated class subject](./casl-discriminated-class-subject.png)

The same parameter allows to infer `modelName` static property from classes (in case you want to use strings and not classes to check on subject type)

![CASL Typescript infer class modelName](./casl-class-subject-with-name.png)
![CASL TypeScript infer class modelName](./casl-class-subject-with-name.png)

Moreover, the same behavior also works in complementary packages! So, you will get hints for React's `Can` component, Vue's `$can` function, Mongoose's plugins and others.

Expand Down
6 changes: 3 additions & 3 deletions docs-src/src/content/pages/guide/define-rules/en.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export default function defineAbilityFor(user) {

It's not required to use `AbilityBuilder` to define rules in the app, especially if your rules are dynamic (i.e., stored in database or managed by admin users). In such cases, the preferred way is to use `JSON` objects. You can directly pass array of `JSON` rules into `Ability` constructor. Such rules are called raw rules

> you can read more about typescript types and their shapes in [Typescript Support](../../advanced/typescript)
> you can read more about TypeScript types and their shapes in [TypeScript Support](../../advanced/typescript)
### JSON objects example

Expand All @@ -172,7 +172,7 @@ Pay attention to the `inverted` field, it indicates that a rule is an inverted o

### The shape of raw rule

The simplified version (without generics) of raw rule shape in [Typescript](http://www.typescriptlang.org/) looks like this:
The simplified version (without generics) of raw rule shape in [TypeScript](http://www.typescriptlang.org/) looks like this:

```ts
interface RawRule {
Expand All @@ -191,7 +191,7 @@ interface RawRule {

Don't worry if you are not familiar with TypeScript, you still have time to learn it ;) Kidding, or not?

In the example above, `?` after field name means optional field, so everything is optional except `action`. `string[]` means an array of strings and `string | string[]` means either regular `string` or an array of strings. Now you know almost everything about Typescript, do not thank :)
In the example above, `?` after field name means optional field, so everything is optional except `action`. `string[]` means an array of strings and `string | string[]` means either regular `string` or an array of strings. Now you know almost everything about TypeScript, do not thank :)

### When to use JSON objects

Expand Down
2 changes: 1 addition & 1 deletion packages/casl-vue/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ And update `tsconfig.json` to replace default vue modules augmentation (i.e., `@
}
```

> Read [Vue Typescript](https://vuejs.org/v2/guide/typescript.html) to understand why it's so hard to properly type Vue plugins.
> Read [Vue TypeScript](https://vuejs.org/v2/guide/typescript.html) to understand why it's so hard to properly type Vue plugins.
## Update Ability instance

Expand Down

0 comments on commit 9173c18

Please sign in to comment.