Skip to content

Conversation

@adriancuadrado
Copy link
Contributor

In the this-based type guards subsection of the this Types section there is an example that uses a parameter property. This may confuse readers that are reading this article from top to bottom since you are using a feature that has not been explained yet.

In the `this-based type guards`](https://www.typescriptlang.org/docs/handbook/2/classes.html#this-based-type-guards) subsection of the [`this Types`](https://www.typescriptlang.org/docs/handbook/2/classes.html#this-types) section there is an example that uses a parameter property. This may confuse readers that are reading this article from top to bottom since you are using a feature that has not been explained yet.
@adriancuadrado
Copy link
Contributor Author

This is the example code that uses parameter properties:

class FileSystemObject {
  isFile(): this is FileRep {
    return this instanceof FileRep;
  }
  isDirectory(): this is Directory {
    return this instanceof Directory;
  }
  isNetworked(): this is Networked & this {
    return this.networked;
  }
  constructor(public path: string, private networked: boolean) {}
}

This code is used in this-based type guards, but it is in the next section, where they are actually explained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant