Skip to content

TS7018 error without file and line numberΒ #58150

Closed
@ktrz

Description

@ktrz

πŸ”Ž Search Terms

filename, noImplicitAny, TS7018, 7018

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about TS7018, line number, filename

⏯ Playground Link

https://www.typescriptlang.org/play?strict=false&strictNullChecks=false&jsx=0&ssl=9&ssc=14&pln=8&pc=7#code/GYVwdgxgLglg9mABAEzgZSgCwOoywBQEMAnQgWwGcAKABxPIoC5FwBrMOAdzAEpEBvAFCJEMYIipQAnjQCmccXVKVEAQgC86xAHI4AIwBWs6Nr5CRI4rKghiSfgF8A3MMQPBrqzbsDXIiMzawHBw2gA0fog0gXok4ZFMOrEAXvEizoLughAIFFCIscSIWuZRzGAgADaVESKJFdW1iAB0ragYOHiYRMrUpSLROpiy1aFNdYGccMSVyGluPBEZQA

πŸ’» Code

function doSthWithParams(params: unknown) {
  if (typeof params !== 'object') {
    return {};
  }

  return {
    c: 'foo',
    p: 'bar',
    s: 'baz',
  };
}

const bar = {
  p: null,
  s: null,
  ...doSthWithParams({
    p: 'hello',
    s: 'world',
  }),
};

πŸ™ Actual behavior

We're trying to incrementally get our codebase toward the strict mode. When we've enabled noImplicitAny flag we got an error that was very hard to track as it didn't give a file and line number where the error happens.

Object literal's property 'p' implicitly has an 'any' type.

Object literal's property 's' implicitly has an 'any' type.

πŸ™‚ Expected behavior

The TS compiler error should point to a file and line number where the error occurs

Additional information about the issue

This happens if noImplicitAny is true and strictNullChecks is not yet enabled

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions