-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🤖 Pick PR #59337 (Allow declarationMap to be emitted ...) into releas…
…e-5.5 (#59344) Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
- Loading branch information
1 parent
9dd6f91
commit b075332
Showing
16 changed files
with
955 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
128 changes: 128 additions & 0 deletions
128
tests/baselines/reference/transpile/declarationBasicSyntax(declarationMap=true).d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
//// [variables.ts] //// | ||
export const a = 1; | ||
export let b = 2; | ||
export var c = 3; | ||
using d = undefined; | ||
export { d }; | ||
await using e = undefined; | ||
export { e }; | ||
//// [interface.ts] //// | ||
export interface Foo { | ||
a: string; | ||
readonly b: string; | ||
c?: string; | ||
} | ||
//// [class.ts] //// | ||
const i = Symbol(); | ||
export class Bar { | ||
a: string; | ||
b?: string; | ||
declare c: string; | ||
#d: string; | ||
public e: string; | ||
protected f: string; | ||
private g: string; | ||
["h"]: string; | ||
[i]: string; | ||
} | ||
|
||
export abstract class Baz { | ||
abstract a: string; | ||
abstract method(): void; | ||
} | ||
//// [namespace.ts] //// | ||
export namespace ns { | ||
namespace internal { | ||
export class Foo {} | ||
} | ||
export namespace nested { | ||
export import inner = internal; | ||
} | ||
} | ||
//// [alias.ts] //// | ||
export type A<T> = { x: T }; | ||
//// [variables.d.ts] //// | ||
export declare const a = 1; | ||
export declare let b: number; | ||
export declare var c: number; | ||
declare const d: any; | ||
export { d }; | ||
declare const e: any; | ||
export { e }; | ||
//# sourceMappingURL=variables.d.ts.map | ||
//// [variables.d.ts.map] //// | ||
{"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["variables.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,CAAC,IAAI,CAAC;AACnB,eAAO,IAAI,CAAC,QAAI,CAAC;AACjB,eAAO,IAAI,CAAC,QAAI,CAAC;AACjB,QAAA,MAAM,CAAC,KAAY,CAAC;AACpB,OAAO,EAAE,CAAC,EAAE,CAAC;AACb,QAAA,MAAY,CAAC,KAAY,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,CAAC"} | ||
//// [interface.d.ts] //// | ||
export interface Foo { | ||
a: string; | ||
readonly b: string; | ||
c?: string; | ||
} | ||
//# sourceMappingURL=interface.d.ts.map | ||
//// [interface.d.ts.map] //// | ||
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,GAAG;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,CAAC,CAAC,EAAE,MAAM,CAAC;CACd"} | ||
//// [class.d.ts] //// | ||
export declare class Bar { | ||
#private; | ||
a: string; | ||
b?: string; | ||
c: string; | ||
e: string; | ||
protected f: string; | ||
private g; | ||
["h"]: string; | ||
} | ||
export declare abstract class Baz { | ||
abstract a: string; | ||
abstract method(): void; | ||
} | ||
//# sourceMappingURL=class.d.ts.map | ||
//// [class.d.ts.map] //// | ||
{"version":3,"file":"class.d.ts","sourceRoot":"","sources":["class.ts"],"names":[],"mappings":"AACA,qBAAa,GAAG;;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,CAAC,EAAE,MAAM,CAAC;IACH,CAAC,EAAE,MAAM,CAAC;IAEX,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,CAAC,CAAS;IAClB,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CAEjB;AAED,8BAAsB,GAAG;IACrB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,MAAM,IAAI,IAAI;CAC1B"} | ||
|
||
|
||
//// [Diagnostics reported] | ||
class.ts(11,5): error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations. | ||
|
||
|
||
==== class.ts (1 errors) ==== | ||
const i = Symbol(); | ||
export class Bar { | ||
a: string; | ||
b?: string; | ||
declare c: string; | ||
#d: string; | ||
public e: string; | ||
protected f: string; | ||
private g: string; | ||
["h"]: string; | ||
[i]: string; | ||
~~~ | ||
!!! error TS9038: Computed property names on class or object literals cannot be inferred with --isolatedDeclarations. | ||
} | ||
|
||
export abstract class Baz { | ||
abstract a: string; | ||
abstract method(): void; | ||
} | ||
//// [namespace.d.ts] //// | ||
export declare namespace ns { | ||
namespace internal { | ||
class Foo { | ||
} | ||
} | ||
export namespace nested { | ||
export import inner = internal; | ||
} | ||
export {}; | ||
} | ||
//# sourceMappingURL=namespace.d.ts.map | ||
//// [namespace.d.ts.map] //// | ||
{"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["namespace.ts"],"names":[],"mappings":"AAAA,yBAAiB,EAAE,CAAC;IAChB,UAAU,QAAQ,CAAC;QACf,MAAa,GAAG;SAAG;KACtB;IACD,MAAM,WAAW,MAAM,CAAC;QACpB,MAAM,QAAQ,KAAK,GAAG,QAAQ,CAAC;KAClC;;CACJ"} | ||
//// [alias.d.ts] //// | ||
export type A<T> = { | ||
x: T; | ||
}; | ||
//# sourceMappingURL=alias.d.ts.map | ||
//// [alias.d.ts.map] //// | ||
{"version":3,"file":"alias.d.ts","sourceRoot":"","sources":["alias.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,CAAC,CAAC,CAAC,IAAI;IAAE,CAAC,EAAE,CAAC,CAAA;CAAE,CAAC"} |
140 changes: 140 additions & 0 deletions
140
tests/baselines/reference/transpile/declarationBasicSyntax(declarationMap=true).js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
//// [variables.ts] //// | ||
export const a = 1; | ||
export let b = 2; | ||
export var c = 3; | ||
using d = undefined; | ||
export { d }; | ||
await using e = undefined; | ||
export { e }; | ||
//// [interface.ts] //// | ||
export interface Foo { | ||
a: string; | ||
readonly b: string; | ||
c?: string; | ||
} | ||
//// [class.ts] //// | ||
const i = Symbol(); | ||
export class Bar { | ||
a: string; | ||
b?: string; | ||
declare c: string; | ||
#d: string; | ||
public e: string; | ||
protected f: string; | ||
private g: string; | ||
["h"]: string; | ||
[i]: string; | ||
} | ||
|
||
export abstract class Baz { | ||
abstract a: string; | ||
abstract method(): void; | ||
} | ||
//// [namespace.ts] //// | ||
export namespace ns { | ||
namespace internal { | ||
export class Foo {} | ||
} | ||
export namespace nested { | ||
export import inner = internal; | ||
} | ||
} | ||
//// [alias.ts] //// | ||
export type A<T> = { x: T }; | ||
//// [variables.js] //// | ||
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { | ||
if (value !== null && value !== void 0) { | ||
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); | ||
var dispose, inner; | ||
if (async) { | ||
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); | ||
dispose = value[Symbol.asyncDispose]; | ||
} | ||
if (dispose === void 0) { | ||
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); | ||
dispose = value[Symbol.dispose]; | ||
if (async) inner = dispose; | ||
} | ||
if (typeof dispose !== "function") throw new TypeError("Object not disposable."); | ||
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } }; | ||
env.stack.push({ value: value, dispose: dispose, async: async }); | ||
} | ||
else if (async) { | ||
env.stack.push({ async: true }); | ||
} | ||
return value; | ||
}; | ||
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { | ||
return function (env) { | ||
function fail(e) { | ||
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; | ||
env.hasError = true; | ||
} | ||
function next() { | ||
while (env.stack.length) { | ||
var rec = env.stack.pop(); | ||
try { | ||
var result = rec.dispose && rec.dispose.call(rec.value); | ||
if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); | ||
} | ||
catch (e) { | ||
fail(e); | ||
} | ||
} | ||
if (env.hasError) throw env.error; | ||
} | ||
return next(); | ||
}; | ||
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { | ||
var e = new Error(message); | ||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; | ||
}); | ||
export const a = 1; | ||
export let b = 2; | ||
export var c = 3; | ||
export { d }; | ||
export { e }; | ||
var d, e; | ||
const env_1 = { stack: [], error: void 0, hasError: false }; | ||
try { | ||
d = __addDisposableResource(env_1, undefined, false); | ||
e = __addDisposableResource(env_1, undefined, true); | ||
} | ||
catch (e_1) { | ||
env_1.error = e_1; | ||
env_1.hasError = true; | ||
} | ||
finally { | ||
const result_1 = __disposeResources(env_1); | ||
if (result_1) | ||
await result_1; | ||
} | ||
//// [interface.js] //// | ||
export {}; | ||
//// [class.js] //// | ||
var _Bar_d; | ||
const i = Symbol(); | ||
export class Bar { | ||
constructor() { | ||
_Bar_d.set(this, void 0); | ||
} | ||
} | ||
_Bar_d = new WeakMap(); | ||
export class Baz { | ||
} | ||
//// [namespace.js] //// | ||
export var ns; | ||
(function (ns) { | ||
let internal; | ||
(function (internal) { | ||
class Foo { | ||
} | ||
internal.Foo = Foo; | ||
})(internal || (internal = {})); | ||
let nested; | ||
(function (nested) { | ||
nested.inner = internal; | ||
})(nested = ns.nested || (ns.nested = {})); | ||
})(ns || (ns = {})); | ||
//// [alias.js] //// | ||
export {}; |
Oops, something went wrong.