61cb06ce40
* Allow allowJs and declaration to be used together This intorduces a new symbol-based declaration emitter - currently this is only used for JSON and JavaScript, as the output is likely worse than what the other declaration emitter is capable of. In addition, it is still incomplete - it does not yet support serializaing namespaces. * Add tests for various import/export forms, add notes on export as namespace and fix export * from * Tests & fixes for computed names * Add test with current @enum tag behavior * fix declaration emit for jsdoc @enum tags * Small adjustments to base class serialization to fix bugs in it * Guard against type/type parameter confusion when using typeParameterToName a bit * Integrate feedback from PR * Fix issue with export= declarations visibility calculation and type declaration emit that impacted all forms of declaration emit * Only make one merged getCommonJsExportEquals symbol for a symbol * Support preserving type reference directives in js declarations * Skip declare mdoifiers for namespace members in ambient contexts * FAKE ALIASES AND NAMESPACES EVERYWHERE * Dont do namespace sugar when type members contain keyword names * Fix json source file export modifier under new output * Such clean nested aliasing, very wow * Fix lint * Add visibility errors, reuse type nodes where possible * Suppoer having correctly named import types in bundled js declaration emit & adjust binding to allow namespaces with aliases to merge when the aliases look to be type-only * Better support for module.exports = class expression * Fix discovered crash bug * Allow export assigned class expressions to be reachable symbols from external declarations * Add missing semicolon * Support @enum tag post-merge * preserve comments on signatures and declarations where possible * Basic support for js classy functions * Add example we should do better with * Prototype assignments make things a bit wonky, but the example from the PR seems OK * Make a ton of changes to support the new way js classes are bound * Remove some old comments, fix import and export default names * Fix bug in object define handling and add tests for object define property declaration emit * Fix organization nits from PR comments * Preserve comments from jsdoc declarations on properties and js declaration type aliases * Merge export declarations with identical specifiers * Remove completed TODO comment * Split lint * Remove now-unused function * PR feedback * Add some project references tests, remove some checks from project refs codepaths that are now invalid * Update project references tests again * Merge and update project references tests * Rename case * Update test to include declaration output * Remove yet another project refernces redirect extension check * Update comment * Add additional import ref to test * Add shorthand prop to test * Fix comment text * Extract var to temp * Simplify function and add whitespace * Update project refs test to use incremental edit entry * Stylistic refactors in the symbol serializer * Another round of PR feedback, mostly style, small bugfix with constructors, and test showing bug in export assigned class expression name shadowing * Use x instead of index
125 lines
2.2 KiB
TypeScript
125 lines
2.2 KiB
TypeScript
// @allowJs: true
|
|
// @checkJs: true
|
|
// @target: es5
|
|
// @outDir: ./out
|
|
// @declaration: true
|
|
// @filename: index.js
|
|
|
|
// Pretty much all of this should be an error, (since interfaces are forbidden in js),
|
|
// but we should be able to synthesize declarations from the symbols regardless
|
|
|
|
export interface A {}
|
|
|
|
export interface B {
|
|
cat: string;
|
|
}
|
|
|
|
export interface C<T, U> {
|
|
field: T & U;
|
|
optionalField?: T;
|
|
readonly readonlyField: T & U;
|
|
readonly readonlyOptionalField?: U;
|
|
(): number;
|
|
(x: T): U;
|
|
<Q>(x: Q): T & Q;
|
|
|
|
new (): string;
|
|
new (x: T): U;
|
|
new <Q>(x: Q): T & Q;
|
|
|
|
method<Q = number>(): number;
|
|
method<Q>(a: T & Q): Q & number;
|
|
method(a?: number): number;
|
|
method(...args: any[]): number;
|
|
|
|
optMethod?(): number;
|
|
}
|
|
|
|
interface G {}
|
|
|
|
export { G };
|
|
|
|
interface HH {}
|
|
|
|
export { HH as H };
|
|
|
|
export interface I {}
|
|
export { I as II };
|
|
|
|
export { J as JJ };
|
|
export interface J {}
|
|
|
|
export interface K extends I,J {
|
|
x: string;
|
|
}
|
|
|
|
export interface L extends K {
|
|
y: string;
|
|
}
|
|
|
|
export interface M<T> {
|
|
field: T;
|
|
}
|
|
|
|
export interface N<U> extends M<U> {
|
|
other: U;
|
|
}
|
|
|
|
export interface O {
|
|
[idx: string]: string;
|
|
}
|
|
|
|
export interface P extends O {}
|
|
|
|
export interface Q extends O {
|
|
[idx: string]: "ok";
|
|
}
|
|
|
|
export interface R extends O {
|
|
[idx: number]: "ok";
|
|
}
|
|
|
|
export interface S extends O {
|
|
[idx: string]: "ok";
|
|
[idx: number]: never;
|
|
}
|
|
|
|
export interface T {
|
|
[idx: number]: string;
|
|
}
|
|
|
|
export interface U extends T {}
|
|
|
|
|
|
export interface V extends T {
|
|
[idx: string]: string;
|
|
}
|
|
|
|
export interface W extends T {
|
|
[idx: number]: "ok";
|
|
}
|
|
|
|
export interface X extends T {
|
|
[idx: string]: string;
|
|
[idx: number]: "ok";
|
|
}
|
|
|
|
export interface Y {
|
|
[idx: string]: {x: number};
|
|
[idx: number]: {x: number, y: number};
|
|
}
|
|
|
|
export interface Z extends Y {}
|
|
|
|
export interface AA extends Y {
|
|
[idx: string]: {x: number, y: number};
|
|
}
|
|
|
|
export interface BB extends Y {
|
|
[idx: number]: {x: 0, y: 0};
|
|
}
|
|
|
|
export interface CC extends Y {
|
|
[idx: string]: {x: number, y: number};
|
|
[idx: number]: {x: 0, y: 0};
|
|
}
|