mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-27 23:58:38 -06:00
Don’t issue used-before-initialization errors in declaration files (#32579)
This commit is contained in:
parent
73bef22f0b
commit
33f362abaf
@ -20700,7 +20700,7 @@ namespace ts {
|
||||
|
||||
function checkPropertyNotUsedBeforeDeclaration(prop: Symbol, node: PropertyAccessExpression | QualifiedName, right: Identifier): void {
|
||||
const { valueDeclaration } = prop;
|
||||
if (!valueDeclaration) {
|
||||
if (!valueDeclaration || getSourceFileOfNode(node).isDeclarationFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
=== tests/cases/compiler/declaration.d.ts ===
|
||||
export declare class ClassWithSymbols {
|
||||
>ClassWithSymbols : Symbol(ClassWithSymbols, Decl(declaration.d.ts, 0, 0))
|
||||
|
||||
public readonly [Namespace.locallyExportedCustomSymbol]: string;
|
||||
>[Namespace.locallyExportedCustomSymbol] : Symbol(ClassWithSymbols[Namespace.locallyExportedCustomSymbol], Decl(declaration.d.ts, 0, 39))
|
||||
>Namespace.locallyExportedCustomSymbol : Symbol(Namespace.locallyExportedCustomSymbol, Decl(declaration.d.ts, 5, 14))
|
||||
>Namespace : Symbol(Namespace, Decl(declaration.d.ts, 3, 1))
|
||||
>locallyExportedCustomSymbol : Symbol(Namespace.locallyExportedCustomSymbol, Decl(declaration.d.ts, 5, 14))
|
||||
|
||||
public [Namespace.fullyExportedCustomSymbol](): void;
|
||||
>[Namespace.fullyExportedCustomSymbol] : Symbol(ClassWithSymbols[Namespace.fullyExportedCustomSymbol], Decl(declaration.d.ts, 1, 66))
|
||||
>Namespace.fullyExportedCustomSymbol : Symbol(Namespace.fullyExportedCustomSymbol, Decl(declaration.d.ts, 6, 14))
|
||||
>Namespace : Symbol(Namespace, Decl(declaration.d.ts, 3, 1))
|
||||
>fullyExportedCustomSymbol : Symbol(Namespace.fullyExportedCustomSymbol, Decl(declaration.d.ts, 6, 14))
|
||||
}
|
||||
export namespace Namespace {
|
||||
>Namespace : Symbol(Namespace, Decl(declaration.d.ts, 3, 1))
|
||||
|
||||
export const locallyExportedCustomSymbol: unique symbol;
|
||||
>locallyExportedCustomSymbol : Symbol(locallyExportedCustomSymbol, Decl(declaration.d.ts, 5, 14))
|
||||
|
||||
export const fullyExportedCustomSymbol: unique symbol;
|
||||
>fullyExportedCustomSymbol : Symbol(fullyExportedCustomSymbol, Decl(declaration.d.ts, 6, 14))
|
||||
}
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
=== tests/cases/compiler/declaration.d.ts ===
|
||||
export declare class ClassWithSymbols {
|
||||
>ClassWithSymbols : ClassWithSymbols
|
||||
|
||||
public readonly [Namespace.locallyExportedCustomSymbol]: string;
|
||||
>[Namespace.locallyExportedCustomSymbol] : string
|
||||
>Namespace.locallyExportedCustomSymbol : unique symbol
|
||||
>Namespace : typeof Namespace
|
||||
>locallyExportedCustomSymbol : unique symbol
|
||||
|
||||
public [Namespace.fullyExportedCustomSymbol](): void;
|
||||
>[Namespace.fullyExportedCustomSymbol] : () => void
|
||||
>Namespace.fullyExportedCustomSymbol : unique symbol
|
||||
>Namespace : typeof Namespace
|
||||
>fullyExportedCustomSymbol : unique symbol
|
||||
}
|
||||
export namespace Namespace {
|
||||
>Namespace : typeof Namespace
|
||||
|
||||
export const locallyExportedCustomSymbol: unique symbol;
|
||||
>locallyExportedCustomSymbol : unique symbol
|
||||
|
||||
export const fullyExportedCustomSymbol: unique symbol;
|
||||
>fullyExportedCustomSymbol : unique symbol
|
||||
}
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
// @filename: declaration.d.ts
|
||||
|
||||
export declare class ClassWithSymbols {
|
||||
public readonly [Namespace.locallyExportedCustomSymbol]: string;
|
||||
public [Namespace.fullyExportedCustomSymbol](): void;
|
||||
}
|
||||
export namespace Namespace {
|
||||
export const locallyExportedCustomSymbol: unique symbol;
|
||||
export const fullyExportedCustomSymbol: unique symbol;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user