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.

Inconsistent ending for type

See original GitHub issue

I believe that the one we should have is what flow is outputting. Does someone have more context around why there’s a difference here?

Flow

--parser babel
export type Block = {
  format: BlockFormat,
  lang: BlockLanguage
}

Typescript

--parser typescript
type Block = {
  format: BlockFormat;
  lang: BlockLanguage;
};

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
thorn0commented, Aug 29, 2020

Object types in TS are anonymous interfaces. They can contain everything named interfaces can, e.g. method signatures, which look really strange with commas:

let a: {
    foo(): number,
    bar(): string,
    bar(baz: string): void,
    (): void,
};

The relationship between object types and interfaces closely resembles the one between function expressions and function declarations. A function expression can be assigned to a variable (let f = ...) to achieve almost the same effect a function declaration would have, but still function declarations have some extra behavior, namely hoisting. Same with object types and interfaces. If you assign an object type to an alias (type t = ...), it will be almost the same thing as an interface declaration, but it won’t have the extra behavior interface declarations have, namely declaration merging.

The point I’m making is that using different formatting for object types and interfaces is very much like using different formatting for function expressions and function declarations. Not only inconsistent, it’d be also misleading, making object types and interfaces look more different than they actually are.

1reaction
seahindenizcommented, May 7, 2020

I didn’t read that before and now did.

Everybody wants to add just a tiny piece of configuration to satisfy their use case. As a result we end up with inconsistently designed tools, with unexpected combinations that don’t work correctly, with bugs and regressions that, when fixed in one configuration, break something else with another configuration.

I can say and confirm that this isn’t directly related to my use case. I’m simply referring is that Typescript has support for comma delimiter since 2015 and there is no enforcement that restricts us to use semicolon in type/interface definitions. We can agree there isn’t going to be a bug in both usages, am I right?

Btw. the tab width example is just to show that you there is no restriction between both usages, therefore, there shouldn’t be for delimiters.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What does Visual Studio mean by normalize inconsistent line ...
Normalizing inconsistent line endings in Visual Studio means selecting one character type to be used for all your files. It could be:.
Read more >
A little program to look for files with inconsistent line endings
The main program takes the files enumerated by EnumerateFiles , ignores certain known binary file types, and for the remaining files, counts the ......
Read more >
Inconsistent Line Endings - YouTube
This is a video that goes over what inconsistent line endings are and how you can understand them as well as resolve them....
Read more >
Solving inconsistent line endings within a Git repository
If you develop code on both Windows and Linux machines you might have run into inconsistent line endings. This might lead to "empty"...
Read more >
inconsistent line endings - Unity Forum
There are inconsistent line endings in the 'someFileName.cs' script. ... I'm using VisualStudio 2012 to write my scripts and I used to get ......
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