mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
Merge pull request #13103 from Microsoft/metadataOfClassFromModule
Update current scope when visiting namespace elements
This commit is contained in:
commit
0c2cce565c
@ -2731,7 +2731,7 @@ namespace ts {
|
||||
let blockLocation: TextRange;
|
||||
const body = node.body;
|
||||
if (body.kind === SyntaxKind.ModuleBlock) {
|
||||
addRange(statements, visitNodes((<ModuleBlock>body).statements, namespaceElementVisitor, isStatement));
|
||||
saveStateAndInvoke(body, body => addRange(statements, visitNodes((<ModuleBlock>body).statements, namespaceElementVisitor, isStatement)));
|
||||
statementsLocation = (<ModuleBlock>body).statements;
|
||||
blockLocation = body;
|
||||
}
|
||||
|
||||
44
tests/baselines/reference/metadataOfClassFromModule.js
Normal file
44
tests/baselines/reference/metadataOfClassFromModule.js
Normal file
@ -0,0 +1,44 @@
|
||||
//// [metadataOfClassFromModule.ts]
|
||||
module MyModule {
|
||||
|
||||
export function inject(target: any, key: string): void { }
|
||||
|
||||
export class Leg { }
|
||||
|
||||
export class Person {
|
||||
@inject leftLeg: Leg;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//// [metadataOfClassFromModule.js]
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var MyModule;
|
||||
(function (MyModule) {
|
||||
function inject(target, key) { }
|
||||
MyModule.inject = inject;
|
||||
var Leg = (function () {
|
||||
function Leg() {
|
||||
}
|
||||
return Leg;
|
||||
}());
|
||||
MyModule.Leg = Leg;
|
||||
var Person = (function () {
|
||||
function Person() {
|
||||
}
|
||||
return Person;
|
||||
}());
|
||||
__decorate([
|
||||
inject,
|
||||
__metadata("design:type", Leg)
|
||||
], Person.prototype, "leftLeg", void 0);
|
||||
MyModule.Person = Person;
|
||||
})(MyModule || (MyModule = {}));
|
||||
22
tests/baselines/reference/metadataOfClassFromModule.symbols
Normal file
22
tests/baselines/reference/metadataOfClassFromModule.symbols
Normal file
@ -0,0 +1,22 @@
|
||||
=== tests/cases/compiler/metadataOfClassFromModule.ts ===
|
||||
module MyModule {
|
||||
>MyModule : Symbol(MyModule, Decl(metadataOfClassFromModule.ts, 0, 0))
|
||||
|
||||
export function inject(target: any, key: string): void { }
|
||||
>inject : Symbol(inject, Decl(metadataOfClassFromModule.ts, 0, 17))
|
||||
>target : Symbol(target, Decl(metadataOfClassFromModule.ts, 2, 27))
|
||||
>key : Symbol(key, Decl(metadataOfClassFromModule.ts, 2, 39))
|
||||
|
||||
export class Leg { }
|
||||
>Leg : Symbol(Leg, Decl(metadataOfClassFromModule.ts, 2, 62))
|
||||
|
||||
export class Person {
|
||||
>Person : Symbol(Person, Decl(metadataOfClassFromModule.ts, 4, 24))
|
||||
|
||||
@inject leftLeg: Leg;
|
||||
>inject : Symbol(inject, Decl(metadataOfClassFromModule.ts, 0, 17))
|
||||
>leftLeg : Symbol(Person.leftLeg, Decl(metadataOfClassFromModule.ts, 6, 25))
|
||||
>Leg : Symbol(Leg, Decl(metadataOfClassFromModule.ts, 2, 62))
|
||||
}
|
||||
|
||||
}
|
||||
22
tests/baselines/reference/metadataOfClassFromModule.types
Normal file
22
tests/baselines/reference/metadataOfClassFromModule.types
Normal file
@ -0,0 +1,22 @@
|
||||
=== tests/cases/compiler/metadataOfClassFromModule.ts ===
|
||||
module MyModule {
|
||||
>MyModule : typeof MyModule
|
||||
|
||||
export function inject(target: any, key: string): void { }
|
||||
>inject : (target: any, key: string) => void
|
||||
>target : any
|
||||
>key : string
|
||||
|
||||
export class Leg { }
|
||||
>Leg : Leg
|
||||
|
||||
export class Person {
|
||||
>Person : Person
|
||||
|
||||
@inject leftLeg: Leg;
|
||||
>inject : (target: any, key: string) => void
|
||||
>leftLeg : Leg
|
||||
>Leg : Leg
|
||||
}
|
||||
|
||||
}
|
||||
14
tests/cases/compiler/metadataOfClassFromModule.ts
Normal file
14
tests/cases/compiler/metadataOfClassFromModule.ts
Normal file
@ -0,0 +1,14 @@
|
||||
// @experimentalDecorators: true
|
||||
// @emitDecoratorMetadata: true
|
||||
// @target: es5
|
||||
module MyModule {
|
||||
|
||||
export function inject(target: any, key: string): void { }
|
||||
|
||||
export class Leg { }
|
||||
|
||||
export class Person {
|
||||
@inject leftLeg: Leg;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user