Don't skip markLinkedReferences on ambient properties (#59325)
This commit is contained in:
Родитель
2640db8b39
Коммит
95a968ce6b
|
@ -29704,8 +29704,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
|||
if (!canCollectSymbolAliasAccessabilityData) {
|
||||
return;
|
||||
}
|
||||
if (location.flags & NodeFlags.Ambient) {
|
||||
return; // References within types and declaration files are never going to contribute to retaining a JS import
|
||||
if (location.flags & NodeFlags.Ambient && !isPropertySignature(location) && !isPropertyDeclaration(location)) {
|
||||
// References within types and declaration files are never going to contribute to retaining a JS import,
|
||||
// except for properties (which can be decorated).
|
||||
return;
|
||||
}
|
||||
switch (hint) {
|
||||
case ReferenceHint.Identifier:
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
//// [tests/cases/compiler/decoratorMetadataElidedImportOnDeclare.ts] ////
|
||||
|
||||
//// [observable.d.ts]
|
||||
export declare class Observable<T> {}
|
||||
|
||||
//// [index.ts]
|
||||
import { Observable } from './observable';
|
||||
|
||||
function whatever(a: any, b: any) {}
|
||||
|
||||
class Test {
|
||||
@whatever
|
||||
declare prop: Observable<string>;
|
||||
}
|
||||
|
||||
|
||||
//// [index.js]
|
||||
"use strict";
|
||||
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);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const observable_1 = require("./observable");
|
||||
function whatever(a, b) { }
|
||||
class Test {
|
||||
}
|
||||
__decorate([
|
||||
whatever,
|
||||
__metadata("design:type", observable_1.Observable)
|
||||
], Test.prototype, "prop", void 0);
|
|
@ -0,0 +1,27 @@
|
|||
//// [tests/cases/compiler/decoratorMetadataElidedImportOnDeclare.ts] ////
|
||||
|
||||
=== observable.d.ts ===
|
||||
export declare class Observable<T> {}
|
||||
>Observable : Symbol(Observable, Decl(observable.d.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(observable.d.ts, 0, 32))
|
||||
|
||||
=== index.ts ===
|
||||
import { Observable } from './observable';
|
||||
>Observable : Symbol(Observable, Decl(index.ts, 0, 8))
|
||||
|
||||
function whatever(a: any, b: any) {}
|
||||
>whatever : Symbol(whatever, Decl(index.ts, 0, 42))
|
||||
>a : Symbol(a, Decl(index.ts, 2, 18))
|
||||
>b : Symbol(b, Decl(index.ts, 2, 25))
|
||||
|
||||
class Test {
|
||||
>Test : Symbol(Test, Decl(index.ts, 2, 36))
|
||||
|
||||
@whatever
|
||||
>whatever : Symbol(whatever, Decl(index.ts, 0, 42))
|
||||
|
||||
declare prop: Observable<string>;
|
||||
>prop : Symbol(Test.prop, Decl(index.ts, 4, 12))
|
||||
>Observable : Symbol(Observable, Decl(index.ts, 0, 8))
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
//// [tests/cases/compiler/decoratorMetadataElidedImportOnDeclare.ts] ////
|
||||
|
||||
=== observable.d.ts ===
|
||||
export declare class Observable<T> {}
|
||||
>Observable : Observable<T>
|
||||
> : ^^^^^^^^^^^^^
|
||||
|
||||
=== index.ts ===
|
||||
import { Observable } from './observable';
|
||||
>Observable : typeof Observable
|
||||
> : ^^^^^^^^^^^^^^^^^
|
||||
|
||||
function whatever(a: any, b: any) {}
|
||||
>whatever : (a: any, b: any) => void
|
||||
> : ^ ^^ ^^ ^^ ^^^^^^^^^
|
||||
>a : any
|
||||
>b : any
|
||||
|
||||
class Test {
|
||||
>Test : Test
|
||||
> : ^^^^
|
||||
|
||||
@whatever
|
||||
>whatever : (a: any, b: any) => void
|
||||
> : ^ ^^ ^^ ^^ ^^^^^^^^^
|
||||
|
||||
declare prop: Observable<string>;
|
||||
>prop : Observable<string>
|
||||
> : ^^^^^^^^^^^^^^^^^^
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
//// [tests/cases/compiler/decoratorMetadataElidedImportOnDeclare.ts] ////
|
||||
|
||||
//// [observable.d.ts]
|
||||
export declare class Observable<T> {}
|
||||
|
||||
//// [index.ts]
|
||||
import { Observable } from './observable';
|
||||
|
||||
function whatever(a: any, b: any) {}
|
||||
|
||||
class Test {
|
||||
@whatever
|
||||
declare prop: Observable<string>;
|
||||
}
|
||||
|
||||
|
||||
//// [index.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);
|
||||
};
|
||||
import { Observable } from './observable';
|
||||
function whatever(a, b) { }
|
||||
class Test {
|
||||
}
|
||||
__decorate([
|
||||
whatever,
|
||||
__metadata("design:type", Observable)
|
||||
], Test.prototype, "prop", void 0);
|
|
@ -0,0 +1,27 @@
|
|||
//// [tests/cases/compiler/decoratorMetadataElidedImportOnDeclare.ts] ////
|
||||
|
||||
=== observable.d.ts ===
|
||||
export declare class Observable<T> {}
|
||||
>Observable : Symbol(Observable, Decl(observable.d.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(observable.d.ts, 0, 32))
|
||||
|
||||
=== index.ts ===
|
||||
import { Observable } from './observable';
|
||||
>Observable : Symbol(Observable, Decl(index.ts, 0, 8))
|
||||
|
||||
function whatever(a: any, b: any) {}
|
||||
>whatever : Symbol(whatever, Decl(index.ts, 0, 42))
|
||||
>a : Symbol(a, Decl(index.ts, 2, 18))
|
||||
>b : Symbol(b, Decl(index.ts, 2, 25))
|
||||
|
||||
class Test {
|
||||
>Test : Symbol(Test, Decl(index.ts, 2, 36))
|
||||
|
||||
@whatever
|
||||
>whatever : Symbol(whatever, Decl(index.ts, 0, 42))
|
||||
|
||||
declare prop: Observable<string>;
|
||||
>prop : Symbol(Test.prop, Decl(index.ts, 4, 12))
|
||||
>Observable : Symbol(Observable, Decl(index.ts, 0, 8))
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
//// [tests/cases/compiler/decoratorMetadataElidedImportOnDeclare.ts] ////
|
||||
|
||||
=== observable.d.ts ===
|
||||
export declare class Observable<T> {}
|
||||
>Observable : Observable<T>
|
||||
> : ^^^^^^^^^^^^^
|
||||
|
||||
=== index.ts ===
|
||||
import { Observable } from './observable';
|
||||
>Observable : typeof Observable
|
||||
> : ^^^^^^^^^^^^^^^^^
|
||||
|
||||
function whatever(a: any, b: any) {}
|
||||
>whatever : (a: any, b: any) => void
|
||||
> : ^ ^^ ^^ ^^ ^^^^^^^^^
|
||||
>a : any
|
||||
>b : any
|
||||
|
||||
class Test {
|
||||
>Test : Test
|
||||
> : ^^^^
|
||||
|
||||
@whatever
|
||||
>whatever : (a: any, b: any) => void
|
||||
> : ^ ^^ ^^ ^^ ^^^^^^^^^
|
||||
|
||||
declare prop: Observable<string>;
|
||||
>prop : Observable<string>
|
||||
> : ^^^^^^^^^^^^^^^^^^
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
// @target: es2020
|
||||
// @module: commonjs, esnext
|
||||
// @strict: true
|
||||
// @experimentalDecorators: true
|
||||
// @emitDecoratorMetadata: true
|
||||
|
||||
// @filename: observable.d.ts
|
||||
export declare class Observable<T> {}
|
||||
|
||||
// @filename: index.ts
|
||||
import { Observable } from './observable';
|
||||
|
||||
function whatever(a: any, b: any) {}
|
||||
|
||||
class Test {
|
||||
@whatever
|
||||
declare prop: Observable<string>;
|
||||
}
|
Загрузка…
Ссылка в новой задаче