Add tests when declaration emit for indirect alias usuage results in wrong error reporting

Test for #22257
This commit is contained in:
Sheetal Nandi 2018-03-02 16:10:34 -08:00
parent 87c3cca3f0
commit dc7ee381d5
5 changed files with 249 additions and 0 deletions

View file

@ -0,0 +1,31 @@
tests/cases/compiler/app.ts(3,16): error TS2503: Cannot find namespace 'fp'.
==== tests/cases/compiler/locale.d.ts (0 errors) ====
export type Locale = {
weekdays: {
shorthand: [string, string, string, string, string, string, string];
longhand: [string, string, string, string, string, string, string];
};
};
export type CustomLocale = {
weekdays: {
shorthand: [string, string, string, string, string, string, string];
longhand: [string, string, string, string, string, string, string];
};
};
export type key = "ar" | "bg";
==== tests/cases/compiler/instance.d.ts (0 errors) ====
import { Locale, CustomLocale, key as LocaleKey } from "./locale";
export interface FlatpickrFn {
l10ns: {[k in LocaleKey]?: CustomLocale } & { default: Locale };
}
==== tests/cases/compiler/app.ts (1 errors) ====
import { FlatpickrFn } from "./instance";
const fp = { l10ns: {} } as FlatpickrFn;
export default fp.l10ns;
~~
!!! error TS2503: Cannot find namespace 'fp'.

View file

@ -0,0 +1,59 @@
//// [tests/cases/compiler/declarationEmitAliasFromIndirectFile.ts] ////
//// [locale.d.ts]
export type Locale = {
weekdays: {
shorthand: [string, string, string, string, string, string, string];
longhand: [string, string, string, string, string, string, string];
};
};
export type CustomLocale = {
weekdays: {
shorthand: [string, string, string, string, string, string, string];
longhand: [string, string, string, string, string, string, string];
};
};
export type key = "ar" | "bg";
//// [instance.d.ts]
import { Locale, CustomLocale, key as LocaleKey } from "./locale";
export interface FlatpickrFn {
l10ns: {[k in LocaleKey]?: CustomLocale } & { default: Locale };
}
//// [app.ts]
import { FlatpickrFn } from "./instance";
const fp = { l10ns: {} } as FlatpickrFn;
export default fp.l10ns;
//// [app.js]
"use strict";
exports.__esModule = true;
var fp = { l10ns: {} };
exports["default"] = fp.l10ns;
//// [app.d.ts]
declare const _default: {
ar?: {
weekdays: {
shorthand: [string, string, string, string, string, string, string];
longhand: [string, string, string, string, string, string, string];
};
};
bg?: {
weekdays: {
shorthand: [string, string, string, string, string, string, string];
longhand: [string, string, string, string, string, string, string];
};
};
} & {
default: {
weekdays: {
shorthand: [string, string, string, string, string, string, string];
longhand: [string, string, string, string, string, string, string];
};
};
};
export default _default;

View file

@ -0,0 +1,64 @@
=== tests/cases/compiler/locale.d.ts ===
export type Locale = {
>Locale : Symbol(Locale, Decl(locale.d.ts, 0, 0))
weekdays: {
>weekdays : Symbol(weekdays, Decl(locale.d.ts, 0, 22))
shorthand: [string, string, string, string, string, string, string];
>shorthand : Symbol(shorthand, Decl(locale.d.ts, 1, 15))
longhand: [string, string, string, string, string, string, string];
>longhand : Symbol(longhand, Decl(locale.d.ts, 2, 76))
};
};
export type CustomLocale = {
>CustomLocale : Symbol(CustomLocale, Decl(locale.d.ts, 5, 2))
weekdays: {
>weekdays : Symbol(weekdays, Decl(locale.d.ts, 6, 28))
shorthand: [string, string, string, string, string, string, string];
>shorthand : Symbol(shorthand, Decl(locale.d.ts, 7, 15))
longhand: [string, string, string, string, string, string, string];
>longhand : Symbol(longhand, Decl(locale.d.ts, 8, 76))
};
};
export type key = "ar" | "bg";
>key : Symbol(key, Decl(locale.d.ts, 11, 2))
=== tests/cases/compiler/instance.d.ts ===
import { Locale, CustomLocale, key as LocaleKey } from "./locale";
>Locale : Symbol(Locale, Decl(instance.d.ts, 0, 8))
>CustomLocale : Symbol(CustomLocale, Decl(instance.d.ts, 0, 16))
>key : Symbol(LocaleKey, Decl(instance.d.ts, 0, 30))
>LocaleKey : Symbol(LocaleKey, Decl(instance.d.ts, 0, 30))
export interface FlatpickrFn {
>FlatpickrFn : Symbol(FlatpickrFn, Decl(instance.d.ts, 0, 66))
l10ns: {[k in LocaleKey]?: CustomLocale } & { default: Locale };
>l10ns : Symbol(FlatpickrFn.l10ns, Decl(instance.d.ts, 1, 30))
>k : Symbol(k, Decl(instance.d.ts, 2, 13))
>LocaleKey : Symbol(LocaleKey, Decl(instance.d.ts, 0, 30))
>CustomLocale : Symbol(CustomLocale, Decl(instance.d.ts, 0, 16))
>default : Symbol(default, Decl(instance.d.ts, 2, 49))
>Locale : Symbol(Locale, Decl(instance.d.ts, 0, 8))
}
=== tests/cases/compiler/app.ts ===
import { FlatpickrFn } from "./instance";
>FlatpickrFn : Symbol(FlatpickrFn, Decl(app.ts, 0, 8))
const fp = { l10ns: {} } as FlatpickrFn;
>fp : Symbol(fp, Decl(app.ts, 1, 5))
>l10ns : Symbol(l10ns, Decl(app.ts, 1, 12))
>FlatpickrFn : Symbol(FlatpickrFn, Decl(app.ts, 0, 8))
export default fp.l10ns;
>fp : Symbol(fp, Decl(app.ts, 1, 5))
>l10ns : Symbol(FlatpickrFn.l10ns, Decl(instance.d.ts, 1, 30))

View file

@ -0,0 +1,68 @@
=== tests/cases/compiler/locale.d.ts ===
export type Locale = {
>Locale : Locale
weekdays: {
>weekdays : { shorthand: [string, string, string, string, string, string, string]; longhand: [string, string, string, string, string, string, string]; }
shorthand: [string, string, string, string, string, string, string];
>shorthand : [string, string, string, string, string, string, string]
longhand: [string, string, string, string, string, string, string];
>longhand : [string, string, string, string, string, string, string]
};
};
export type CustomLocale = {
>CustomLocale : CustomLocale
weekdays: {
>weekdays : { shorthand: [string, string, string, string, string, string, string]; longhand: [string, string, string, string, string, string, string]; }
shorthand: [string, string, string, string, string, string, string];
>shorthand : [string, string, string, string, string, string, string]
longhand: [string, string, string, string, string, string, string];
>longhand : [string, string, string, string, string, string, string]
};
};
export type key = "ar" | "bg";
>key : key
=== tests/cases/compiler/instance.d.ts ===
import { Locale, CustomLocale, key as LocaleKey } from "./locale";
>Locale : any
>CustomLocale : any
>key : any
>LocaleKey : any
export interface FlatpickrFn {
>FlatpickrFn : FlatpickrFn
l10ns: {[k in LocaleKey]?: CustomLocale } & { default: Locale };
>l10ns : { ar?: CustomLocale; bg?: CustomLocale; } & { default: Locale; }
>k : k
>LocaleKey : LocaleKey
>CustomLocale : CustomLocale
>default : Locale
>Locale : Locale
}
=== tests/cases/compiler/app.ts ===
import { FlatpickrFn } from "./instance";
>FlatpickrFn : any
const fp = { l10ns: {} } as FlatpickrFn;
>fp : FlatpickrFn
>{ l10ns: {} } as FlatpickrFn : FlatpickrFn
>{ l10ns: {} } : { l10ns: {}; }
>l10ns : {}
>{} : {}
>FlatpickrFn : FlatpickrFn
export default fp.l10ns;
>fp.l10ns : { ar?: { weekdays: { shorthand: [string, string, string, string, string, string, string]; longhand: [string, string, string, string, string, string, string]; }; }; bg?: { weekdays: { shorthand: [string, string, string, string, string, string, string]; longhand: [string, string, string, string, string, string, string]; }; }; } & { default: { weekdays: { shorthand: [string, string, string, string, string, string, string]; longhand: [string, string, string, string, string, string, string]; }; }; }
>fp : FlatpickrFn
>l10ns : { ar?: { weekdays: { shorthand: [string, string, string, string, string, string, string]; longhand: [string, string, string, string, string, string, string]; }; }; bg?: { weekdays: { shorthand: [string, string, string, string, string, string, string]; longhand: [string, string, string, string, string, string, string]; }; }; } & { default: { weekdays: { shorthand: [string, string, string, string, string, string, string]; longhand: [string, string, string, string, string, string, string]; }; }; }

View file

@ -0,0 +1,27 @@
// @declaration: true
// @filename: locale.d.ts
export type Locale = {
weekdays: {
shorthand: [string, string, string, string, string, string, string];
longhand: [string, string, string, string, string, string, string];
};
};
export type CustomLocale = {
weekdays: {
shorthand: [string, string, string, string, string, string, string];
longhand: [string, string, string, string, string, string, string];
};
};
export type key = "ar" | "bg";
// @filename: instance.d.ts
import { Locale, CustomLocale, key as LocaleKey } from "./locale";
export interface FlatpickrFn {
l10ns: {[k in LocaleKey]?: CustomLocale } & { default: Locale };
}
// @filename: app.ts
import { FlatpickrFn } from "./instance";
const fp = { l10ns: {} } as FlatpickrFn;
export default fp.l10ns;