microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.18k stars 12.38k forks source link

Incremental type checking failure (regression) #38354

Open falsandtru opened 4 years ago

falsandtru commented 4 years ago

TypeScript Version: 3.7.x-dev.20200505

Search Terms:

Code

  1. clone https://github.com/falsandtru/typed-dom
  2. npm i
  3. open src/builder.ts (no error)
  4. remove the closing parenthesis of API(html, shadow)
  5. redo
  6. error
Argument of type 'Factory<HTMLElementTagNameMap>' is not assignable to parameter of type 'Factory<ShadowHostElementTagNameMap>'.
  Property ''custom-tag'' is missing in type 'HTMLElementTagNameMap' but required in type 'ShadowHostElementTagNameMap'.ts(2345)

Expected behavior: no error Actual behavior:

Playground Link:

Related Issues:

falsandtru commented 4 years ago

Now the errors always appear on the latest VSCode. The following different error is simpler but this second error appears only after the first error is caused. Of course all the errors don't appear in compilation.

  1. open test\integration\package.ts
  2. error with HTML('custom-tag')
Argument of type '"custom-tag"' is not assignable to parameter of type '"object" | "article" | "aside" | "blockquote" | "body" | "div" | "footer" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "header" | "main" | "nav" | "p" | "section" | "span" | "a" | "abbr" | ... 98 more ... | "custom"'.ts(2345)

Looks like the errors come from the wrong conflict between the following definitions:

// index.ts
declare global {
  interface ShadowHostElementTagNameMap extends ShadowHostElementTagNameMap_ {
  }
  interface HTMLElementTagNameMap extends ShadowHostElementTagNameMap {
  }
}
// test\integration\package.ts
declare global {
  interface ShadowHostElementTagNameMap {
    'custom-tag': HTMLElement;
  }
  interface HTMLElementTagNameMap {
    'custom': HTMLElement;
  }
}

@rbuckton @sheetalkamat