question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type errors with strict rule

See original GitHub issue

We are running into issues with typescript throwing errors when running with the strict: true option in tsconfig.json.

This is the output from tsc:

node_modules/@interactjs/types/index.d.ts:267:18 - error TS2428: All declarations of 'BaseEvent' must have identical type parameters.

267     export class BaseEvent<T extends ActionName | null = never> {
                     ~~~~~~~~~

node_modules/@interactjs/types/index.d.ts:287:22 - error TS2428: All declarations of 'BaseEvent' must have identical type parameters.

287     export interface BaseEvent<T extends ActionName> {
                         ~~~~~~~~~

node_modules/@interactjs/types/index.d.ts:2487:34 - error TS2344: Type 'T' does not satisfy the constraint 'keyof ActionMap'.
  Type 'keyof ActionMap | null' is not assignable to type 'keyof ActionMap'.
    Type 'null' is not assignable to type 'keyof ActionMap'.
      Type 'T' is not assignable to type '"gesture"'.
        Type 'keyof ActionMap | null' is not assignable to type '"gesture"'.
          Type 'null' is not assignable to type '"gesture"'.

2487         prevEvent: InteractEvent<T, EventPhase>;
                                      ~

node_modules/@interactjs/types/index.d.ts:2588:135 - error TS2344: Type 'T' does not satisfy the constraint 'keyof ActionMap'.

2588         _createPreparedEvent<P extends EventPhase>(event: PointerEventType, phase: P, preEnd?: boolean, type?: string): InteractEvent<T, P>;
                                                                                                                                           ~

node_modules/@interactjs/types/index.d.ts:2589:64 - error TS2344: Type 'T' does not satisfy the constraint 'keyof ActionMap'.

2589         _fireEvent<P extends EventPhase>(iEvent: InteractEvent<T, P>): void;
                                                                    ~

node_modules/@interactjs/types/index.d.ts:2590:67 - error TS2344: Type 'T' does not satisfy the constraint 'keyof ActionMap'.

2590         _doPhase<P extends EventPhase>(signalArg: Omit<DoPhaseArg<T, P>, 'iEvent'> & {
                                                                       ~

node_modules/@interactjs/types/index.d.ts:2591:36 - error TS2344: Type 'T' does not satisfy the constraint 'keyof ActionMap'.

2591             iEvent?: InteractEvent<T, P>;

I’ve tried to override these myself, to get typescript to stop complaining, with no luck (yet) since the types are part of the library.

Our tsconfig:

{
    "compilerOptions": {
        "allowJs": true,
        "allowSyntheticDefaultImports": true,
        "baseUrl": "./client",
        "experimentalDecorators": true,
        "jsx": "react",
        "module": "commonjs",
        "noEmit": true,
        "noImplicitAny": true,
        "pretty": true,
        "strict": true,
        "target": "es2019",
        "paths": {
            "generated/*": ["../generated/*.ts"]
        }
    },
    "include": ["index.ts"]
}

This is with Typescript 4.2.3 but I’ve tried it with the 4.3.5 as well

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
saeldioncommented, Apr 7, 2022

No disrespect but skipLibCheck is not really a solution, it’s just a band-aid. Why have typescript support if it’s faulty?

3reactions
spieralacommented, Dec 10, 2021

Here same issue, Angular 11, TypeScript 4.1.6

workaround: add “skipLibCheck”: true in the tsconfig compilerOptions

Read more comments on GitHub >

github_iconTop Results From Across the Web

How strict is Typescript's strict mode? - DEV Community ‍ ‍
In strict mode, it actually throws errors on all undefined properties not defined in the constructor. This helps you review the code and...
Read more >
Controlling type checking strictness | Learn TypeScript
For JavaScript migration projects, strict can be set to true with the other flags to false if the corresponding rule raises lots of...
Read more >
Strict mode - JavaScript - MDN Web Docs
Strict mode changes some previously-accepted mistakes into errors. ... Strict mode makes it easier to write "secure" JavaScript.
Read more >
Controlling Type Checking Strictness in TypeScript
There is a TypeScript compiler option called strict . This turns on a set of type checking rules and is referred to as...
Read more >
What Is Strict Mode In TypeScript, Why And When You Should ...
For example, one of the rules forces you to always write a type of ... rules of strict mode then you probably will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found