Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the typedefs and docs for updateTag to match how FXP actually behaves #579

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ChrisMBarr
Copy link
Contributor

@ChrisMBarr ChrisMBarr commented May 28, 2023

Purpose / Goal

According to the comments in discussion #576 the updateTag method actually allows for the undefined return type. This PR makes two simple changes:

  • It updates the TypeScript type definitions to match the behavior
  • It updates the docs to better describe the behavior and gives an output sample from the example code

Type

  • Bug Fix
  • Refactoring / Technology upgrade
  • New Feature
  • Docs & TypeDefs update

Regarding the typedefs update

Currently returning undefined while using typescript will give this error

Type '(tagName: string, jPath: string, attrs: { [k: string]: string; }) => false | "A" | undefined' is not assignable to type '(tagName: string, jPath: string, attrs: { [k: string]: string; }) => string | boolean'.
  Type 'false | "A" | undefined' is not assignable to type 'string | boolean'.
    Type 'undefined' is not assignable to type 'string | boolean'.ts(2322)

The update the the typedefs will fix this and allow this to happen.

Regarding the docs update

A note about the example output in the docs that I added. This is the exact output when I tested it by running the code example given in the docs. It seems to say that "At": "Home" is added as an attribute on the A tag, but also "At": "Home" seems to be added as an element. This seems odd to me but I'm also somewhat new to FXP and I'm not sure if this is intended behavior or not. Regardless though, this is what the output is, and now the docs will give an example of that.

##Regarding returning undefined
As far as I can tell when updateTag method has return undefined, it behaves exactly the same as return false. The docs and the typedefs now explicitly mention that.

@ChrisMBarr ChrisMBarr changed the title Change the typedefs and docs to match how FXP actually behaves Change the typedefs and docs for updateTag to match how FXP actually behaves May 28, 2023
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.

None yet

1 participant