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

@smui/common - typescript errors when noUncheckedIndexedAccess compiler option is enabled #531

Closed
DetachHead opened this issue Nov 4, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@DetachHead
Copy link
Contributor

Describe the bug

c:\project\node_modules\@smui\common\src\internal\useActions.ts:42:11
Error: Cannot invoke an object which is possibly 'undefined'. 
        actionReturns.push(
          action(node as HTMLElement & SVGElement, actionEntry[1])
        );


c:\project\node_modules\@smui\common\src\internal\useActions.ts:45:28
Error: Cannot invoke an object which is possibly 'undefined'.
      } else {
        actionReturns.push(action(node as HTMLElement & SVGElement));
      }


c:\project\node_modules\@smui\common\src\internal\exclude.ts:10:23
Error: Object is possibly 'undefined'.
    const name = names[i];
    const cashIndex = name.indexOf('$');
    if (


c:\project\node_modules\@smui\common\src\internal\exclude.ts:13:20
Error: Object is possibly 'undefined'.
      cashIndex !== -1 &&
      keys.indexOf(name.substring(0, cashIndex + 1)) !== -1
    ) {


c:\project\node_modules\@smui\common\src\internal\exclude.ts:17:22
Error: Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
  Type 'undefined' is not assignable to type 'string'.
    }
    if (keys.indexOf(name) !== -1) {
      continue;


c:\project\node_modules\@smui\common\src\internal\exclude.ts:20:44
Error: Type 'undefined' cannot be used as an index type.
    }
    newObj[name as keyof Partial<T>] = obj[name];
  }


c:\project\node_modules\@smui\common\src\internal\forwardEventsBuilder.ts:75:17
Error: Object is possibly 'undefined'.
              ? ':' + newEventTypeParts[i]
              : newEventTypeParts[i]
                  .split('-')


c:\project\node_modules\@smui\common\src\internal\forwardEventsBuilder.ts:99:9
Error: Type 'string | undefined' is not assignable to type 'string'.
  Type 'undefined' is not assignable to type 'string'.
        const parts = eventType.split(oldModifierMatch ? ':' : '$');
        eventType = parts[0];
        const eventOptions: {


c:\project\node_modules\@smui\common\src\internal\forwardEventsBuilder.ts:157:11
Error: Object is possibly 'undefined'.
      // Listen to all the events added before mount.
      $on(events[i][0], events[i][1]);
    }


c:\project\node_modules\@smui\common\src\internal\forwardEventsBuilder.ts:157:25
Error: Object is possibly 'undefined'.
      // Listen to all the events added before mount.
      $on(events[i][0], events[i][1]);
    }


c:\project\node_modules\@smui\common\src\internal\forwardEventsBuilder.ts:164:11
Error: Cannot invoke an object which is possibly 'undefined'.
        for (let i = 0; i < destructors.length; i++) {
          destructors[i]();
        }


c:\project\node_modules\@smui\common\src\internal\prefixFilter.ts:10:9
Error: Object is possibly 'undefined'.
    const name = names[i];
    if (name.substring(0, prefix.length) === prefix) {
      newObj[name.substring(prefix.length)] = obj[name];


c:\project\node_modules\@smui\common\src\internal\prefixFilter.ts:11:14
Error: Object is possibly 'undefined'.
    if (name.substring(0, prefix.length) === prefix) {
      newObj[name.substring(prefix.length)] = obj[name];
    }


c:\project\node_modules\@smui\common\src\internal\prefixFilter.ts:11:51
Error: Type 'undefined' cannot be used as an index type.
    if (name.substring(0, prefix.length) === prefix) {
      newObj[name.substring(prefix.length)] = obj[name];
    }

To Reproduce

  1. enable noUncheckedIndexedAccess in tsconfig.json:
    {
        "compilerOptions": {
            "strict": true,
            "noUncheckedIndexedAccess": true,
            "skipLibCheck": false
        }
    }
  2. run svelte-check

Expected behavior
no errors

@DetachHead DetachHead added the bug Something isn't working label Nov 4, 2022
@DetachHead DetachHead changed the title @smui\common - typescript errors when noUncheckedIndexedAccess compiler option is enabled @smui/common - typescript errors when noUncheckedIndexedAccess compiler option is enabled Nov 4, 2022
@DetachHead
Copy link
Contributor Author

after some investigating i noticed that this is caused by typesVersions in the @smui/common package incorrectly pointing to the source code. see #532

@DetachHead DetachHead closed this as not planned Won't fix, can't repro, duplicate, stale Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant