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

Correctly define ReadyCallback parameter type #144

Merged
merged 1 commit into from
Jun 13, 2022
Merged

Correctly define ReadyCallback parameter type #144

merged 1 commit into from
Jun 13, 2022

Conversation

daveallie
Copy link
Contributor

@daveallie daveallie commented Jun 13, 2022

The existing ReadyCallback type is not valid TypeScript, resulting in a TS error when using the @fullstory/browser package.

This issue was introduced in v1.6.0.

This PR adjusts the type definition to be correct.

@luser
Copy link
Contributor

luser commented Jun 13, 2022

Hi, thanks for the report and corresponding fix! Can you provide details of your TypeScript version and configuration? We don't have rigorous TypeScript checks in the CI on this project, but I did manual integration testing with an example project and didn't encounter this issue, so I assume it must be specific to the compiler version or options.

I want to re-verify your change with that example project but it's a very simple fix so it should be no problem to get it merged and push a point release.

Copy link
Contributor

@luser luser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, and worked in my local integration testing. Thanks!

@luser luser merged commit 600ab00 into fullstorydev:main Jun 13, 2022
@daveallie
Copy link
Contributor Author

daveallie commented Jun 13, 2022

Apologies for not being clearer here, this is specifically for strict mode (specifically because of the noImplicitAny rule).

Smallest replicable example

package.json:

{
  "name": "fullstory-example",
  "version": "1.0.0",
  "license": "MIT",
  "dependencies": {
    "@fullstory/browser": "1.6.0"
  },
  "devDependencies": {
    "typescript": "^4.7.3"
  }
}

tsconfig.json:

{
  "compilerOptions": {
    "strict": true
  }
}

index.ts:

import * as FullStory from '@fullstory/browser';

Error:

❯ yarn tsc --noEmit
yarn run v1.22.17
$ /Users/david/tmp/fullstory-example/node_modules/.bin/tsc --noEmit
node_modules/@fullstory/browser/dist/index.d.ts:39:37 - error TS7031: Binding element 'string' implicitly has an 'any' type.

39 type ReadyCallback = ({ sessionUrl: string }) => void;
                                       ~~~~~~


Found 1 error in node_modules/@fullstory/browser/dist/index.d.ts:39

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

So while technically the type is parsable, it results in an unexpected definition which doesn't match the author's intent. I'd recommend running your tsc checks with strict mode enabled, it should catch small things like this, but also prevent incomplete or partial type definitions being published.

@daveallie daveallie deleted the fix/ts-types branch June 13, 2022 23:26
@luser
Copy link
Contributor

luser commented Jun 14, 2022

Thanks for the clarification! I pushed out a 1.6.1 release with your fix. This will be useful when I get to #146.

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.

2 participants