star-micronics / react-native-star-io10

react-native-star-io10 is a library for supporting application development for Star Micronics devices.
Other
88 stars 54 forks source link

Compile errors #15

Closed ShintoTuna closed 1 year ago

ShintoTuna commented 3 years ago

Hello,

I am getting compiler errors when building my project with following compiler options and TS v3.9.9:

"compilerOptions": {
    "lib": ["es2020", "dom"],
    "module": "es2020",
    "target": "es2018",
    "jsx": "react-native",
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "strict": true,
    "noImplicitAny": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "allowJs": true,
    "checkJs": true,
    "preserveConstEnums": true
  }

here is the output i am getting:

$ tsc -p tsconfig.json --noEmit
Error: node_modules/react-native-star-io10/src/StarDeviceDiscoveryManager.ts(82,71): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarDeviceDiscoveryManager.ts(94,71): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarDeviceDiscoveryManagerFactory.ts(12,71): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarIO10Logger.ts(30,71): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarIO10Logger.ts(40,71): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarIO10Logger.ts(51,46): error TS6133: 'nativeObject' is declared but its value is never read.
Error: node_modules/react-native-star-io10/src/StarPrinter.ts(242,71): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarPrinter.ts(257,71): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarPrinter.ts(267,71): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarPrinter.ts(277,71): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarPrinter.ts(289,71): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DisplayBuilder.ts(11,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DisplayBuilder.ts(23,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DisplayBuilder.ts(35,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DisplayBuilder.ts(47,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DisplayBuilder.ts(59,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DisplayBuilder.ts(71,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DisplayBuilder.ts(83,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DisplayBuilder.ts(95,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DisplayBuilder.ts(107,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DisplayBuilder.ts(119,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DocumentBuilder.ts(11,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DocumentBuilder.ts(23,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DocumentBuilder.ts(35,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DocumentBuilder.ts(47,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DocumentBuilder.ts(59,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DocumentBuilder.ts(73,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DocumentBuilder.ts(87,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DocumentBuilder.ts(101,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DocumentBuilder.ts(115,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DocumentBuilder.ts(129,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DocumentBuilder.ts(141,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/DrawerBuilder.ts(11,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/MelodySpeakerBuilder.ts(11,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/MelodySpeakerBuilder.ts(23,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(11,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(23,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(35,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(47,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(59,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(71,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(83,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(95,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(107,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(119,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(131,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(143,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(155,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(167,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(179,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(191,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(203,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(215,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(227,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(239,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(251,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PageModeBuilder.ts(265,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PreSettingBuilder.ts(13,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PreSettingBuilder.ts(27,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PresenterSettingBuilder.ts(11,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PresenterSettingBuilder.ts(23,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(11,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(25,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(37,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(49,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(61,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(73,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(85,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(97,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(109,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(121,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(133,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(145,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(157,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(169,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(181,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(193,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(205,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(217,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(229,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(241,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(253,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(265,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(277,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(289,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/PrinterBuilder.ts(303,75): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/StarXpandCommandBuilder.ts(32,79): error TS2339: Property 'code' does not exist on type 'Error'.
Error: node_modules/react-native-star-io10/src/StarXpandCommand/StarXpandCommandBuilder.ts(45,75): error TS2339: Property 'code' does not exist on type 'Error'.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 1.

By the looks of it the type Error was meant to be overriden somewhere but instead the basic Error type is used and it of course fails as there is not code param on it. Also there is no typescript in package.json dependancies so it is hard to tell wether it may be some TS mismatch.

javascripter commented 3 years ago

I encountered the same tsc errors when trying to integrate this library. I also encountered other compile errors with TypeScript 4.4.2 regarding the below error: error TS1243: 'async' modifier cannot be used with 'abstract' modifier.

For reference, below is the workaround patch I ended up with to compile successfully in my project (using it with patch-package): https://gist.github.com/javascripter/7fcbbbcca2fffe6d0bbec196e082491c

Not too sure about the correct Error typing though, as there wasn't much information in the code.

Brendan-csel commented 2 years ago

I am also seeing many of these same typescript errors Property 'code' does not exist on type 'Error'

I logged the result of the nativeError and see it does have a code property which is a string containing what looks like a guid. So this is definitely a "typing" problem.

I also tried extending the global Error interface in my app (like below), but that failed due some other types the extend Error with an alternate code type.

declare global {
    interface Error {
        code?: string;
    }
}

I think the error catch functions in the Star code need to define their own type instead of using Error.

(cc @bandit-ibayashi )

bemisguided commented 2 years ago

We are having the same issue.

We tried setting up our TypeScript compiler to use the skipLibCheck = true, however, this only tells the TypeScript to skip checking the declaration files (i.e. d.ts ). The SDK doesn't have declaration files and contains just a straight uncompiled TypeScript code.

One recommendation is to compile the TypeScript before packaging. I believe this change, is related to the TypeScript language evolving (Error typing is now more rigorous). At least then project could skipLibCheck = true and not require the SDK to be updated so frequently.

yongmin86k commented 2 years ago

I had the same issue and I had to create a patch file to compile it.

It can be used with patch-package until it is fixed

react-native-star-io10+1.0.0.patch.zip

bemisguided commented 2 years ago

Star and my team have worked together towards a resolution. They provided my team a release to test and it was found to resolve the issue. I'll let them comment on when the fix will be released.

gare-bear commented 2 years ago

Anyone still running into this issue should contact their local Star subsidiary if they're interested in testing a beta release that resolves this issue. For reasons I won't mention here we're not providing pre-release/beta versions through GitHub.

If you're in the US, you can contact the Integration team. For all others, use this page to get support in your region.

gare-bear commented 2 years ago

@ShintoTuna since you initially submitted this issue, can you verify the 1.1.0 release fixes your issue? We'd like to close out this issue and we're pretty confident that 1.1.0 has fixed this.

bandit-ibayashi commented 1 year ago

Since there has been no activity on this Issue for some time and we have released a version that addresses this issue, we would like to close the Issue. If anyone continues to experience the same issue, it would be appreciated if you could submit another Issue.